{"id":"XE-13299","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"444","source_url":"https://github.com/xeprotocol/xe/issues/444","reporter_id":2483,"title":"[net/sync.go] M13: syncPeer() tidak handle context cancellation di tengah sync — resource 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.829451+00:00","updated_at":"2026-11-20T00:51:15.518056+00:00","source_created_at":"2026-11-12T02:52:52+00:00","told_at":"2026-11-20T00:49:36+00:00","status_changed_at":"2026-11-20T00:33:26.090941+00:00","url":"https://bounty.xe.network/XE-13299","body":"## Ringkasan\nKalau context cancelled di tengah `doFullSync`, goroutine tetap jalan sampai selesai. Tidak ada cleanup mechanism.\n\n## Lokasi\n- File: `net/sync.go`\n- Lines: 248-274, 315-331\n\n## Kode\n```go\nfunc (t *tracker) syncPeer(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {\n    ...\n    if err := t.doFullSync(ctx, h, pid, opts...); err != nil {\n        return err\n    }\n    return nil\n}\n\nfunc (t *tracker) doFullSync(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {\n    ...\n    // context cancellation tidak di-handle di tengah sync\n    if err := t.syncData(ctx, h, pid, opts...); err != nil {\n        return err\n    }\n    ...\n}\n```\n\n## Impact\nResource leak kalau context cancelled. Goroutine tetap jalan.\n\n## Suggested Fix\n```go\nfunc (t *tracker) syncPeer(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {\n    ...\n    done := make(chan error, 1)\n    go func() {\n        done <- t.doFullSync(ctx, h, pid, opts...)\n    }()\n    \n    select {\n    case err := <-done:\n        return err\n    case <-ctx.Done():\n        // cleanup jika perlu\n        return ctx.Err()\n    }\n}\n```\n\nAtau implement cancel mechanism di dalam `doFullSync`:\n```go\nfunc (t *tracker) doFullSync(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {\n    ...\n    if err := t.syncData(ctx, h, pid, opts...); err != nil {\n        if ctx.Err() != nil {\n            // cleanup jika context cancelled\n            t.cancelSync(pid)\n        }\n        return err\n    }\n    ...\n}\n```","patch_refs":[],"thread":[{"id":13375,"source":"github","source_ref":"7026795055","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-13299 and says what; it is read like any other.","created_at":"2026-11-20T00:49:36+00:00"}]}