Repository navigation
fix(go): a cancelled stream read waits for its native call - #8428
Conversation
Quest-Claim: afda9ed9af8e68e3
The wrapper returned as soon as ctx ended while the native read kept polling, so a group appended right after could be taken by the abandoned read and destroyed. Reads without an object cancel now let the generated binding cancel its own future and wait for it; CallRelease, now unused, is gone. Unquarantines TestRecvGroupCancelKeepsConsumer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 21 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit 9bc08f5.
No actionable defects found in the wrapper changes. Calling the nil-cancel path inline removes the wrapper's abandoned read, while the object-owned path retains explicit cancellation, WithoutCancel, and disposal of unreceived handles. The two removed CallRelease callers now receive their results directly, and the restored RecvGroup regression test checks reuse after cancellation. Overall direction: the cancellation ownership split looks sound.
Verification limits: GitHub diff/source review of all seven changed files and surrounding bridge/tests; no builds, race tests, or load reproduction run. Generated Go bindings are not checked into this source tree, so their native-future cancellation and result-cleanup behavior was not independently exercised. The reported 300-run result remains author-provided evidence.
There was a problem hiding this comment.
ℹ️ No critical issues — three comments still describe the pre-fix behavior.
Reviewed changes
Reviewed the complete diff: the Go FFI bridge now runs a call without an object cancel inline, so a cancelled stream read waits for the generated binding's own future cancellation; CallRelease and video's frame release are removed with their nil-cancel callers moved to Call; the quarantined RecvGroup test is re-enabled with a new bridge unit test; and the quest is deleted.
bridge.run:cancel == nilnow calls the binding on the caller's goroutine; object-owned calls keep the race,cancel(), and release. This matches the pinned generator'suniffiRustCallAsync, which frees its future onctx.Done()before returning and destroys a result it completed after losing the race.CallRelease/releaseReaddeleted:video.Consumer.NextandClaim.Requestedusebridge.Call; no abandoned result exists on the inline path, and the generator'sdestroyFncovers the enum/optional results these two return.- Tests:
TestRunWaitsForACallWithoutObjectCancelpins the inline behavior, the two release tests force the racy path with an object cancel, andTestRecvGroupCancelKeepsConsumerdrops itst.Skip. - Quest:
go-recv-cancel.mdand its README bullet are removed.
ℹ️ Comments still describe the old racing bridge
Three comments now contradict the code, and one of them records a test as skipped that this PR re-enables. The fixes are comment-only, so this does not block the change.
Technical details
# Stale comments after the inline bridge
## Affected sites
- `quest/m0/test-flakes-2/README.md:246-250` — still says the Go test "is quarantined with `t.Skip` until its child fixes it", but this PR removes the skip and deletes the quest. The README already records resolutions in place (e.g. lines 52-58 and 262-267), so this paragraph should name the fix PR instead.
- `go/wrapper/moq_test.go:1242-1246` — `TestRecvGroupCancelRace` says the native `RecvGroup` "runs on an internal goroutine while ctx ending triggers a concurrent Cancel on the same consumer". `RecvGroup` reaches `run` through `CallHandle(ctx, nil, ...)`, which now calls the binding inline, and ctx ending drops the generated UniFFI future rather than calling `MoqTrackConsumer::cancel`.
- `go/wrapper/internal/bridge/call.go:19` — the summary "run races a blocking FFI call against ctx" now only holds when `cancel != nil`; the paragraphs this PR added say so, but the opening line reads as the opposite.
## Required outcome
- The quest README records that the flake is fixed (or drops the paragraph with the bullet), so no reader thinks the test is still quarantined.
- The two comments describe the inline path and the binding-owned cancellation.deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Summary
Fixes the lost wakeup behind
TestRecvGroupCancelKeepsConsumerand removes itst.Skip.Cause:
bridge.runraced every blocking FFI call againstctxand returned as soon asctxended. The goroutine was left inside the generated binding. For a stream read (no object cancel), that native read could still poll Ready after the caller had moved on. Under load it took the group appended right after,releasedestroyed it, and the nextRecvGroupnever saw it. The Rust waiter staying registered was not the cause.Fix: a call without an object cancel now runs inline. The generated binding already cancels its own UniFFI future on
ctxand destroys a result nobody receives, so the wrapper waits for it instead of racing it. Object-owned calls (Connect, Accept) keep the race,cancel(), and release.CallReleasehad only nil-cancel callers (video.Consumer.Next,Claim.Requested), so its release could never run now. It is deleted, and those callers useCall.TestRunWaitsForACallWithoutObjectCancel. The two release tests now use an object cancel, the only path that still abandons a call.Verification
At a load average near 150, the old
call.gofailed 3 of 300-race -count=300runs (RecvGroup after cancel = context deadline exceeded). With the fix, all 300 passed.just go checkpasses. Fulljust checkdid not run: this is a Go-only change and the host was overloaded.Impact
Public API: none (
bridgeis internal). Wire: none. A cancelled stream read now returns once the native future is cancelled, not immediately.Caused by
Models
Size: S
Implementer: Claude Code, Opus 5.5, unknown effort
(Written by Opus 5.5)
Review
Rewritten by
quest reviewafter each round.01a1c553-effd-7d01-8347-34f7630bf299, round 1The focused fix prevents abandoned reads from consuming subsequent stream items while preserving object-owned cancellation, with regression coverage and no actionable regressions found by source inspection; builds and tests were not run as instructed.