{"id":"XE-13303","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"448","source_url":"https://github.com/xeprotocol/xe/issues/448","reporter_id":2483,"title":"[net/gossip.go] H2: sendToPeer() tidak handle error — goroutine leak","area":"p2p-sync","claimed_tier":null,"assessed_tier":null,"verdict":"invalid","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"invalid","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:08.964952+00:00","updated_at":"2026-11-20T00:51:14.344146+00:00","source_created_at":"2026-11-12T02:53:44+00:00","told_at":"2026-11-20T00:49:32+00:00","status_changed_at":"2026-11-20T00:33:26.041738+00:00","url":"https://bounty.xe.network/XE-13303","body":"## Ringkasan\nKalau `sendToPeer` gagal, error hanya di-log. Tidak ada cleanup. Kalau error terjadi berulang, goroutine yang di-spawn bisa menumpuk.\n\n## Lokasi\n- File: `net/gossip.go`\n- Lines: 189-218\n\n## Kode\n```go\nfunc (g *Gossip) sendToPeer(pid peer.ID, key string, msg []byte) {\n    ...\n    if err := g.sendMessage(pid, key, msg); err != nil {\n        logging.Warnf(\"gossip: failed to send message to %s: %v\", pid, err)\n        return\n    }\n    ...\n}\n\nfunc (g *Gossip) sendMessage(pid peer.ID, key string, msg []byte) error {\n    ...\n    if err := g.host.Connect(g.ctx, peer.AddrInfo{ID: pid}); err != nil {\n        return fmt.Errorf(\"gossip: failed to connect to %s: %w\", pid, err)\n    }\n    ...\n    if err := stream.Close(); err != nil {\n        return fmt.Errorf(\"gossip: failed to close stream: %w\", err)\n    }\n    return nil\n}\n```\n\n## Impact\nGoroutine leak kalau send gagal berulang. Resource exhaustion.\n\n## Suggested Fix\n```go\nfunc (g *Gossip) sendToPeer(pid peer.ID, key string, msg []byte) {\n    ...\n    if err := g.sendMessage(pid, key, msg); err != nil {\n        logging.Warnf(\"gossip: failed to send message to %s: %v\", pid, err)\n        g.mu.Lock()\n        g.failedPeers[pid] = time.Now()\n        g.mu.Unlock()\n        return\n    }\n    ...\n}\n\n// tambah cleanup periodic\nfunc (g *Gossip) cleanupFailedPeers() {\n    g.mu.Lock()\n    now := time.Now()\n    for pid, t := range g.failedPeers {\n        if now.Sub(t) > 5*time.Minute {\n            delete(g.failedPeers, pid)\n        }\n    }\n    g.mu.Unlock()\n}\n```","patch_refs":[],"thread":[{"id":13371,"source":"github","source_ref":"7026793669","author":"XE desk","team":true,"body":"Thanks for the report. We read it against the code and could not confirm a bug in what it describes.\n\nThis report is closed as invalid. If we have missed something, file a new report that links\nhttps://bounty.xe.network/XE-13303 and says what; it is read like any other.","created_at":"2026-11-20T00:49:32+00:00"}]}