From 4ed174bdf33c1556ffcf904264a073e19186d537 Mon Sep 17 00:00:00 2001 From: akrem-chabchoub Date: Wed, 2 Sep 2026 10:04:19 +0200 Subject: [PATCH 1/2] fix: check context cancellation before racing I/O in protobuf reader/writer --- pkg/p2p/protobuf/protobuf.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/p2p/protobuf/protobuf.go b/pkg/p2p/protobuf/protobuf.go index 3153a6e0302..49478dca978 100644 --- a/pkg/p2p/protobuf/protobuf.go +++ b/pkg/p2p/protobuf/protobuf.go @@ -56,6 +56,10 @@ func newReader(r ggio.Reader) Reader { } func (r Reader) ReadMsgWithContext(ctx context.Context, msg proto.Message) error { + if err := ctx.Err(); err != nil { + return err + } + errChan := make(chan error, 1) go func() { errChan <- r.ReadMsg(msg) @@ -78,6 +82,10 @@ func newWriter(r ggio.Writer) Writer { } func (w Writer) WriteMsgWithContext(ctx context.Context, msg proto.Message) error { + if err := ctx.Err(); err != nil { + return err + } + errChan := make(chan error, 1) go func() { errChan <- w.WriteMsg(msg) From 7a40425263ef4387f22e0c6e6c5f69f90a5089e0 Mon Sep 17 00:00:00 2001 From: akrem-chabchoub Date: Wed, 2 Sep 2026 10:08:48 +0200 Subject: [PATCH 2/2] fix: linter --- pkg/p2p/libp2p/stream_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/p2p/libp2p/stream_test.go b/pkg/p2p/libp2p/stream_test.go index 467d239b172..9aab9c1f3a3 100644 --- a/pkg/p2p/libp2p/stream_test.go +++ b/pkg/p2p/libp2p/stream_test.go @@ -79,6 +79,7 @@ func TestStreamVersion(t *testing.T) { if v == nil { t.Fatal("expected version to be non-nil") + return } expected := semver.Version{Major: tc.wantMajor, Minor: tc.wantMinor}