Repository navigation
fix(host-kit): preserve cancellation of live requests #4164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Minor · Removed 50k/10k bound on the request-abort registry is not recorded in any doc or help the repository owns
The registry bound in
request-cancel.tswas a deliberate memory safety valve for the long-lived daemon, and this change removes it, changing a daemon-wide resource-lifetime property. Nothing in the tree records it: the only doc references to this module (docs/adr/0023-end-state-hop-trace.md:80, docs/adr/0033-collocation-decision-table.md:83) speak aboutthrowIfRequestCanceledand file placement, and the only ADR hunk in this PR (docs/adr/0005 line 139) is about the runner's closed-id window, an unrelated journal inside the runner process. The repository's own instruction says "When behavior changes, update the owning help and user docs", and ADR 0005 shows this project documents comparable safety valves and their accepted residual bounds. The unbounded registry with no stated bound or residual-risk acceptance is the kind of decision that belongs in an ADR (the change already ships an ADR edit, so the place exists).Suggested change
Add an ADR (or a paragraph in the daemon-lifecycle ADR) stating that
requestAbortControllersis retained until explicit cleanup, why eviction of live entries was wrong (uncancelable early requests), and what now bounds it or why unbounded is accepted.Details
Also raised here
Also raised at this location by senior-developer: Request-abort registry lost its only bound; a leaked registration now permanently poisons its request id — Removing
evictOldestEntries(requestAbortControllers())means therequestAbortControllersmap is no longer bounded at all: an entry now leaves only throughclearRequestCanceled/clearRequestAbortRegistration.canceledRequestIdskeeps its bound (evictOldestSetEntries, line 105), so the map is now the one unbounded piece of per-runtime state in this module, and every one of the 10 production call sites relies on an explicit cleanup running (http-serverlifetime.release()in thehandleRpcRequest/invokeAdmittedRpcRequestfinallys, transport.ts finally at line 104,withRequestDeadline's finally,bindReplayTestAttemptCancellation.release()). The consequence of any missed cleanup is worse than unbounded memory: the entry keepsrequestAbortControllers().has(requestId)true forever, soregisterRequestAbortthrowsduplicate_request_id(line 84-89) for every later request that reuses that id. …Also raised at this location by javascript: Removing the controllers map's safety valve leaves no bound and permanently poisons a leaked request id —
registerRequestAbortno longer prunesrequestAbortControllers, so the map is bounded only by every caller reaching its cleanup. The sibling collection keeps its bound (markRequestCanceledstill callsevictOldestSetEntries, request-cancel.ts:105), so the module now relies on the unproved invariant that all five production call sites always settle their work: http-server.tsbeginRpcRequestLifetime().release()in thefinallyat http-server.ts:313, transport.ts:104,withRequestDeadline'sfinallyat request-cancel.ts:247, andbindReplayTestAttemptCancellation().release()in the.finally()at session-test-runtime.ts:95-97. Concrete consequence: a handler that never settles — a wedged runner is a documented state in this codebase (RUNNER_WEDGED) — leaks its registration. ……and 1 more (maintainability), left out to fit the comment.
persona:
senior-developer,javascript,maintainabilityReply
@apex-sentinel-staging note ...to add context, or@apex-sentinel-staging pivot ...if this is wrong — I will re-check the cited code.Useful? Reply
@apex-sentinel-staging like, or@apex-sentinel-staging dislike <why>if it is not.