fix(proxy): separate websocket scope cleanup budget - #1723
Open
kevinsslin wants to merge 3 commits into
Open
Conversation
Keep the one-second generic task cancellation bound while allowing normal direct Responses WebSocket scope finalization to use a bounded five-second observation window. Preserve the shared shutdown deadline and add a regression plus OpenSpec contract. Refs Soju06#1711
2 tasks
kevinsslin
marked this pull request as ready for review
August 13, 2026 17:24
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b393380fde
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
kevinsslin
added a commit
to kevinsslin/codex-lb
that referenced
this pull request
Aug 14, 2026
Integrates the reviewed transport reliability fixes from upstream PRs Soju06#1723, Soju06#1726, and Soju06#1736 into the production fork main after combined local validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Direct Responses WebSocket scope teardown reused the generic one-second task-cancellation timeout as its entire normal-operation cleanup budget. Under ordinary load, existing request/lease finalization can exceed that bound and emit
Websocket scope cleanup exceeded its remaining drain budget.This PR gives normal-operation scope teardown a fixed five-second observation budget while preserving the one-second generic child-task cancellation bound and the existing shared shutdown deadline.
Type of change
fix:— bug fixfeat:refactor:Linked issue: Refs #1711
OpenSpec
openspec/changes/websocket-scope-cleanup-budget/Changes
_WEBSOCKET_SCOPE_CLEANUP_TIMEOUT_SECONDS = 5.0for normal direct WebSocket scope finalization._TASK_CANCEL_TIMEOUT_SECONDS = 1.0for ordinary child-task cancellation.Root cause
shutdown_state.remaining_drain_timeout_seconds()returnsNoneduring normal operation. The finalizer then fell back to_TASK_CANCEL_TIMEOUT_SECONDS, which was designed for individual cancellation waits rather than a sequence of request finalization, reservation/lease cleanup, and connection-lease release.Scope
This addresses the cleanup-budget warning and reduces cleanup-induced reconnect pressure. It does not change the upstream
response.createdwatchdog, retry/replay policy, or the terminal outcome of a request that receives no upstream acknowledgement.Test plan
uv run pytest tests/unit/test_websocket_terminal_cancellation.py -q— 27 passeduv run pytest tests/integration/test_proxy_websocket_responses.py -q— 110 passeduv run ruff check app/modules/proxy/_service/websocket/mixin.py tests/unit/test_websocket_terminal_cancellation.pyuv run ruff format --check app/modules/proxy/_service/websocket/mixin.py tests/unit/test_websocket_terminal_cancellation.pyuv run python scripts/check_proxy_architecture.pyuv run ty checknpx --yes @fission-ai/openspec@1.9.0 validate websocket-scope-cleanup-budget --strictnpx --yes @fission-ai/openspec@1.9.0 validate --specs— 50 passedThe new regression was also run against a temporary baseline mutation and failed as expected at the old ~1 second bound, including the warning.
Production evidence
Our codex-lb 1.23.0 deployment observed approximately 15 instances of this warning in the post-upgrade observation window, with 559 successful requests and one ~60-second
missing_response_created_timeout. The timeout/recovery behavior is tracked separately; this PR targets the cleanup budget warning observed alongside it.