fix(events): end a reliable subscription when its context is cancelled

Merged
AR
7h ago
+89-0

Closes #55

  • Once response headers arrive, the HTTP/2 transport checks the request context only while writing the request body. A reliable subscriber that has sent all its acks leaves that writer parked on the empty request pipe, so cancelling the context did not end the blocked Receive until the server sent another message.
  • runReliable now registers context.AfterFunc to close the request and response halves of the stream on cancel; RunEventStream still returns nil, so signalExit keeps the 128+signal exit status.
  • runPlain is unchanged: its request body is closed after the single request, so the transport already watches the context.
  • Adds TestRunEventStreamReliableCancelWhileIdle: the server sends two events, takes both acks, and goes quiet; the test cancels and requires RunEventStream to return nil within 2s. It failed 5/5 before the change.

Checks: make build, make vet, gofmt -s -l, golangci-lint run (0 issues), go test -race ./..., new test with -race -count=30.


Summary by cubic

Fixes reliable subscriptions so cancelling their context ends a blocked Receive instead of stalling until the server sends again. Closes #55.

Once response headers arrive, the HTTP/2 transport checks the request context only while writing the request body. A reliable subscriber that has sent all its acks leaves the writer parked on the empty request pipe, so a cancel didn't end the stream until the next server message. runReliable now registers context.AfterFunc to close both request and response halves on cancel; RunEventStream still returns nil, so the 128+signal exit status is kept. runPlain is unchanged.

Adds TestRunEventStreamReliableCancelWhileIdle, which sends two events, takes both acks, and goes quiet; cancelling must return nil within 2s. The test failed before the change.