Task · TSO-0101

Reject an already-cancelled request before it consumes an admission slot

Description

internal/stream/stream.go around lines 767-768 takes a slot from the admit channel without first checking ctx.Err(). A client that has already gone away therefore consumes admission capacity and proceeds into body processing before anything notices. Minor in isolation, but it interacts with TSO-0059 per-tailnet admission fairness: a route whose clients disconnect under load spends its sub-budget on requests that can never be answered, which is precisely the starvation that task exists to prevent. Check ctx.Err() before acquiring, preserving the existing release callback and success path. Found by the post-Wave-3 sharded CodeRabbit pass.

Acceptance Criteria

Definition of Done

Implementation Plan

Implementation Notes

Final Summary

Admission now rejects pre-cancelled requests and rechecks cancellation after both send branches, releasing any acquired slot. Deterministic regressions failed before the fix and passed after it while preserving live-request release and success behavior.

View the source file on GitHub