<!-- XE-13310 · [net/gossip.go] H9: sendToPeer() tidak handle context cancellation — goroutine leak · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13310>. The page is the record; this is the same page for reading.*

XE-13310 · Bounty

# \[net/gossip.go\] H9: sendToPeer() tidak handle context cancellation — goroutine leak

Closed · invalid
—
[xe#455](https://github.com/xeprotocol/xe/issues/455)
filed 2026-11-12 02:54 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:50 UTC

### Patches

None linked.

### History

- [559440](https://bounty.xe.network/log/559440) 2026-11-20 00:50 UTC reply.mirrored
- [558501](https://bounty.xe.network/log/558501) 2026-11-20 00:49 UTC reply.sent
- [554346](https://bounty.xe.network/log/554346) 2026-11-20 00:37 UTC github.state\_pushed
- [554337](https://bounty.xe.network/log/554337) 2026-11-20 00:37 UTC github.labels
- [553373](https://bounty.xe.network/log/553373) 2026-11-20 00:33 UTC proposal.adopted
- [553198](https://bounty.xe.network/log/553198) 2026-11-20 00:33 UTC proposal.adopted
- [553197](https://bounty.xe.network/log/553197) 2026-11-20 00:33 UTC ticket.status new → closed
- [552873](https://bounty.xe.network/log/552873) 2026-11-20 00:33 UTC proposal.adopted
- [552872](https://bounty.xe.network/log/552872) 2026-11-20 00:33 UTC ticket.facts area
- [552871](https://bounty.xe.network/log/552871) 2026-11-20 00:33 UTC proposal.adopted
- [552870](https://bounty.xe.network/log/552870) 2026-11-20 00:33 UTC ticket.facts
- [550379](https://bounty.xe.network/log/550379) 2026-11-20 00:28 UTC note.added

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

### Report

## Ringkasan

Kalau context cancelled, sendToPeer goroutine tetap berjalan sampai selesai. Tidak ada cleanup mechanism.

## Lokasi

- File: `net/gossip.go`
- Lines: 189-218

## Kode

```
func (g *Gossip) sendToPeer(pid peer.ID, key string, msg []byte) {
    ...
    if err := g.sendMessage(pid, key, msg); err != nil {
        logging.Warnf("gossip: failed to send message to %s: %v", pid, err)
        return
    }
    ...
}

func (g *Gossip) sendMessage(pid peer.ID, key string, msg []byte) error {
    ...
    if err := g.host.Connect(g.ctx, peer.AddrInfo{ID: pid}); err != nil {
        return fmt.Errorf("gossip: failed to connect to %s: %w", pid, err)
    }
    ...
}
```

## Impact

Goroutine leak kalau context cancelled. Resource exhaustion.

## Suggested Fix

```
func (g *Gossip) sendToPeer(ctx context.Context, pid peer.ID, key string, msg []byte) {
    ...
    select {
    case <-ctx.Done():
        return
    default:
        if err := g.sendMessage(ctx, pid, key, msg); err != nil {
            logging.Warnf("gossip: failed to send message to %s: %v", pid, err)
            return
        }
    }
    ...
}
```

### Thread

**XE desk**team2026-11-20 00:50 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-13310 and says what; it is read like any other.
