fix(agent-core-v2): observe aborted source rejections#2161
Open
morluto wants to merge 1 commit into
Open
Conversation
|
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.
Related Issue
No linked issue. This is a focused fix for deterministic promise ownership behavior in the internal v2 engine.
Problem
When
abortable()receives an already-aborted signal, it rejects its returned promise before attaching handlers to the supplied source promise. If that source rejects later, Node emitsunhandledRejection; with the defaultthrowpolicy, that can terminate the process.The MCP reconnect path can create reconnect work before wrapping it with the tool execution signal, making it the clearest affected caller.
What changed
unhandledRejectionboundary for the supplied source promise.This does not attempt to cancel the source operation; it preserves the existing contract while retaining ownership of its eventual rejection.
Test plan
pnpm --filter @moonshot-ai/agent-core-v2 exec vitest run test/_base/utils/abort.test.ts --reporter=verbose— 9 passedpnpm --filter @moonshot-ai/agent-core-v2 test— 4,082 passedpnpm --filter @moonshot-ai/agent-core-v2 typecheck— passedpnpm --filter @moonshot-ai/agent-core-v2 lint:domain— passed for 938 filespnpm exec oxlint --type-aware packages/agent-core-v2/src/_base/utils/abort.ts packages/agent-core-v2/test/_base/utils/abort.test.ts— 0 warnings, 0 errorsChecklist
gen-changesets; no changeset is needed for an internal-onlyagent-core-v2change.