<!-- XE-13301 · [net/sync.go] M15: syncChan tidak di-close saat peer disconnect — goroutine leak · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13301>. The page is the record; this is the same page for reading.*

XE-13301 · Bounty

# \[net/sync.go\] M15: syncChan tidak di-close saat peer disconnect — goroutine leak

Closed · invalid
—
[xe#446](https://github.com/xeprotocol/xe/issues/446)
filed 2026-11-12 02:53 UTC
by wahyu20260100233-ops

Verdict
:   Invalid

Tier
:   —

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:51 UTC

Told
:   2026-11-20 00:49 UTC

### Patches

None linked.

### History

- [557412](https://bounty.xe.network/log/557412) 2026-11-20 00:49 UTC reply.mirrored
- [557078](https://bounty.xe.network/log/557078) 2026-11-20 00:48 UTC reply.sent
- [554152](https://bounty.xe.network/log/554152) 2026-11-20 00:36 UTC github.state\_pushed
- [554148](https://bounty.xe.network/log/554148) 2026-11-20 00:36 UTC github.labels
- [553350](https://bounty.xe.network/log/553350) 2026-11-20 00:33 UTC proposal.adopted
- [553153](https://bounty.xe.network/log/553153) 2026-11-20 00:33 UTC proposal.adopted
- [553152](https://bounty.xe.network/log/553152) 2026-11-20 00:33 UTC ticket.status new → closed
- [552712](https://bounty.xe.network/log/552712) 2026-11-20 00:33 UTC proposal.adopted
- [552711](https://bounty.xe.network/log/552711) 2026-11-20 00:33 UTC ticket.facts area
- [552707](https://bounty.xe.network/log/552707) 2026-11-20 00:33 UTC proposal.adopted
- [552706](https://bounty.xe.network/log/552706) 2026-11-20 00:33 UTC ticket.facts
- [550872](https://bounty.xe.network/log/550872) 2026-11-20 00:31 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-13301) · [JSON](https://bounty.xe.network/v1/tickets/XE-13301) · [markdown](https://bounty.xe.network/XE-13301.md)

### Report

## Ringkasan

`syncCh` di-create di `startPeerSyncWorker` tapi tidak di-close saat peer disconnect. Goroutine yang menunggu di channel tersebut tetap berjalan.

## Lokasi

- File: `net/sync.go`
- Lines: 383-404

## Kode

```
func (t *tracker) startPeerSyncWorker(ctx context.Context, h host.Host, pid peer.ID) {
    t.mu.Lock()
    t.syncCh[pid] = make(chan struct{}, 1)
    t.mu.Unlock()
    go t.peerSyncWorker(ctx, h, pid)
}

func (t *tracker) peerSyncWorker(ctx context.Context, h host.Host, pid peer.ID) {
    ...
    for {
        select {
        case <-ctx.Done():
            return
        case <-t.syncCh[pid]:
            ...
        }
    }
}
```

## Impact

Goroutine leak kalau peer disconnect. Channel tidak di-close.

## Suggested Fix

```
func (t *tracker) stopPeerSyncWorker(pid peer.ID) {
    t.mu.Lock()
    if ch, ok := t.syncCh[pid]; ok {
        close(ch)
        delete(t.syncCh, pid)
    }
    t.mu.Unlock()
}

func (t *tracker) peerSyncWorker(ctx context.Context, h host.Host, pid peer.ID) {
    ...
    for {
        select {
        case <-ctx.Done():
            t.stopPeerSyncWorker(pid)
            return
        case <-t.syncCh[pid]:
            ...
        }
    }
}
```

### Thread

**XE desk**team2026-11-20 00:49 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links
https://bounty.xe.network/XE-13301 and says what; it is read like any other.
