Repository navigation
fix(sdk): prevent checkpoint requests after manager disposal - #1114
Conversation
This comment has been minimized.
This comment has been minimized.
|
/ai review |
Codex AI reviewNo actionable findings. The previous rule 2 concern is addressed; SDK invariants and protected contract tests remain intact. Review was static only: tests and builds were not executed, so runtime race behavior remains unverified. Reviewed commit |
|
@zhongkechen could you please review this |
|
@zhongkechen any updates/comments? |
832bb18 to
7203635
Compare
|
Follow-up pushed: The PR description records an executed pre-fix run on Current Build and conformance workflows require maintainer approval ( |
yaythomas
left a comment
There was a problem hiding this comment.
ready to merge, pending CI.
thank you so much @itsrayeedscodespace, great contribution!
4b16e2c to
d3cb2f7
Compare
|
Thanks, @yaythomas! I really enjoyed working on this and appreciate your guidance through the review. I’d love to keep contributing—if there are any issues you’d like me to take on, or areas you’re looking to enhance or improve, please feel free to assign them to me. I’m happy to help with follow-up work too! |
d3cb2f7 to
28dd1c5
Compare
|
@ParidelPooya thanks for the follow up fixes and review. I see that the earlier approval was dismissed after the latest update, so it looks like a fresh review is also needed. Please let me know if there's anything you'd like me to address, or whether the workflow failure needs a maintainer-side rerun or permissions adjustment. Happy to help. |
8502b8d to
054b480
Compare
Two gaps after dispose(): - A normal return disposes the checkpoint manager but does not run the termination callback. So StepContext.signal was never aborted, and a step the handler did not await was never told to stop. Its next checkpoint now never settles, so the signal is its only stop. The finally block now aborts the signal after dispose(). - A checkpoint in flight at dispose() runs checkAndTerminate() when it completes. That armed a termination timer, which called terminate() on the ended invocation. checkAndTerminate() now returns when disposed. Each new test fails with its fix reverted.
Give the strict installed-consumer typecheck a 30-second timeout, matching the adjacent packaged-consumer compiler test. The Node 22 CI case exceeded the default 5-second limit while compiling TypeScript.
Check completion abort separately from deadline timer cleanup, using a clock that advances with the timer. Update the public signal contract and cleanup comments to match disposal behavior.
55996a2 to
5bb582f
Compare
Issue Link
Closes #1101
Description
After an invocation returns, unfinished work could still submit checkpoints because
CheckpointManager.dispose()did not close checkpoint admission. Disposal now reusessetTerminating()to refuse new requests, andprocessQueue()drops unsent queued work. Ordinary termination still drains its queue. Requests already in flight retain their completion behavior, including force-checkpoint waiters and accepted execution-result checkpoints.Invocation cleanup also aborts
StepContext.signal, allowing steps the handler did not await to stop. The public signal documentation now includes normal return and error exits.checkAndTerminate()refuses to arm a termination timer after disposal.The deadline cleanup test introduced by #1202 now checks two independent outcomes: the signal is aborted when the invocation returns, and advancing beyond the original deadline does not call
terminate()withINVOCATION_DEADLINE_PASSED. FakeDateand timers advance together;setImmediateremains real so checkpoint processing can drain. Runtime behavior is unchanged by this test correction.Design considerations
dispose(): that would discard force-checkpoint waiters attached to an active request.falsetotruewould lose timer-cleanup coverage, so the test observes deadline termination directly. Removing completion abort would leave unfinished steps without their stop signal.Validation
Fresh local checks for the deadline-test and documentation update:
1f3ccda6:does not abort the signal after the invocation returnedfailed withexpected true to be false(1 failed, 7 filtered out).clearTimeout(deadlineTimer)makes the revised test fail on an unexpectedINVOCATION_DEADLINE_PASSEDcall. Independently removing the cleanupterminated.abort()makes it fail on the signal assertion. Both runtime lines were restored before final validation.git diff --checkpassed. The first build attempt lacked a shared Rollup plugin because only core dependencies were installed; installing the additional workspace dependencies from the lockfile resolved the local setup issue.The existing disposal tests cover refused admission, queued work abandoned before dispatch, in-flight completion, execution-result outcomes, termination draining, and absence of termination after disposal. The earlier admission regression evidence recorded in this PR showed two failures on pre-fix parent
48e75ca4, then two passes with the admission fix.The existing OTel installed-consumer typecheck case has a 30-second timeout, matching its adjacent compiler test. In the failed Node 22 job, compilation exceeded Vitest's default five-second limit. Its strict typechecking and assertions are preserved; all seven cases were verified on Node 22.23.4 in the prior timeout follow-up. That package was not rerun for this core test/documentation update.
Scope and unverified behavior
forceRefreshAndCheckStatus()remains outside this fix; subsequent checkpoint dispatch is blocked.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.