Repository navigation
fix: preserve async scope for detached webhook work - #144806
sunlit-deng wants to merge 3 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 11, 2026, 7:01 PM ET / 23:01 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR gives deferred webhook processing its own async-work scope while preserving immediate work reservation, acknowledgement ordering, and drain accounting. Regression provenancePossible regression — suspected (failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 3 items remain The previous P1 finding is resolved, and the current-head runtime evidence is sufficient. Current main and the latest release still need this repair. The overlapping PR retains the same unresolved cancellation-compatibility choice, so it is not yet a safe superseding target. Likely related people: steipete (unverified routing candidate, medium confidence). Priority: P1 Review scores
Verification
How this fits togetherPlugins use the webhook helper to acknowledge HTTP requests before background processing finishes. Gateway work admission tracks that processing and its descendants so suspension and restart can account for unfinished work. flowchart TD
A[Admitted webhook request] --> B[Reserve background work]
B --> C[Write acknowledgement]
B --> D[Create independent async scope]
D --> E[Run deferred callback]
E --> F[Finish tracked descendants]
F --> G[Release work reservation]
Decision needed
Why: This repairs the documented post-ack lifetime, but changes an observable ambient signal for existing third-party callbacks; compatibility acceptance belongs to the SDK/admission owner. Before merge
Agent review detailsSecurityNone. PR surfaceSource +28, Tests +64. Total +92 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the existing public helper and accept its explicitly detached cancellation lifetime while keeping ordinary continuations tied to their callers and all descendants visible to drains. Do we have a high-confidence way to reproduce the issue? Yes: capture the ambient tracker inside deferred webhook work, close the triggering scope, then invoke tracked work. Current-main source explains the rejection, and the contributor supplies matching before/after HTTP traces; this review did not execute code. Is this the best way to solve the issue? Yes, subject to cancellation compatibility acceptance: reusing the existing detached-scope machinery repairs the owner boundary without adding a public SDK API or changing unrelated continuations. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 92c01b7e86de. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
|
Thanks @sunlit-deng for the independent fix, suspension-fence regression, and real HTTP lifetime trace. The equivalent production repair has now landed through #144801 as 48ed702. The detached cancellation contract was accepted in that review, and fresh exact-head CI and Workflow Sanity passed. Closing this as superseded by the landed canonical fix. |
What Problem This Solves
Fixes an issue where plugins that schedule post-ack webhook work could fail with
Async work scope is closedafter the triggering request scope closed.Fixes #144788
Why This Change Was Made
runDetachedWebhookWorknow uses a detached continuation: it reserves the root synchronously from the live parent, including across a closed suspension fence, while executing the callback in a fresh async work scope. This preserves acknowledgement ordering and drain accounting.User Impact
Deferred webhook/plugin work can complete after the triggering request scope closes without becoming untracked or rejected.
Evidence
node --import ./scripts/tsx.mjs webhook-agent-end-runtime-proof.mtsstarted a real TCP/HTTP server and exercisedrunWithGatewayHttpWorkAdmissionthrough the publicrunDetachedWebhookWorkhelper. No external credentials or private data were used.227e7ae2reproducedAsync work scope is closed(exit 1); on this head it completed successfully (exit 0).webhook:detachedroot remained reserved while the triggering scope was closed and was released after tracked work completed. The unchanged inherited-admission negative control still rejects withGateway is draining.webhook-agent-end-runtime-proof.mts
AI-assisted: built with Codex