RunMKVIngestWorker uses ctx cancellation as its "flush the final GoP"
signal after EOS. But muxl's event parser treats a cancelled ctx as
"abandon the stream mid-read": it returns early, nobody reads or closes
the wasm's stdout pipe, and the wasm deadlocks against its next write —
the sign/unwrap call never returns, done never closes, and the worker
hangs forever at `cancel(); <-done`.
While ingest was clock-paced (appsink sync=true) every GoP had drained
long before EOS+cancel arrived, so the race never lost. Once ingest ran
at full speed, EOS+cancel landed while GoPs were still in flight, and
audioCompletionTarget then STARTED a muxl unwrap with an already-dead
ctx — a guaranteed deadlock. That's what wedged GitLab CI's
TestWorkerServesFramesOverSocket into the go test 30m timeout (GitHub's
slower runners kept winning the race).
Fix, in two spots:
- muxlSignSegmentElem: the signer + event drain run on
context.WithoutCancel. Cancel still triggers the flush — it closes the
input pipe, the signer sees EOF, signs the final GoP, and exits
cleanly — it just no longer aborts the parser mid-stream.
- workerSegmentSink: audioCompletionTarget's unwrap likewise runs
WithoutCancel (same reasoning as the transcoder it feeds).
Fallout, both good:
- The old race was silently DROPPING the final GoP even when it didn't
deadlock: the socket e2e test now serves 2 segments (was 1), the
135s-tail sample 31 (was 29).
- The "known issue" from the previous commit — the full 164s production
capture with node transcode keys progressively slowing until the
watchdog fired, then hanging in the post-cancel drain — was this same
bug. It now transcodes the whole capture in ~13s, so
TestMKVIngestMistFullSample's SP_SLOW_TESTS skip-gate is removed.
Upstream follow-up (streamplace/muxl): runWith should close its stdout
pipe reader when parseEvents returns early, so a cancelled ctx can't
permanently wedge a wasm instance; parseEvents' ctx.Done select can also
randomly drop tail events. vod/livehls call sites remain exposed to that
until it's fixed there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>