fix(core): handle processor replacement rejections - #1795
fix(core): handle processor replacement rejections#1795sylvesterkaczmarek wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 47b1a17 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
seratch
left a comment
There was a problem hiding this comment.
The shutdown-rejection path is worth fixing, and the catch belongs at this fire-and-forget boundary. However, handledRejection() already attaches a rejection handler before the SDK receives the Promise, so the current test cannot demonstrate that processor replacement prevents an unhandled rejection.
Please replace that fixture with an actually rejecting processor and verify through the replacement path that the SDK handles the rejection and the replacement remains usable. Keep the implementation scoped to the existing asynchronous processor contract.
|
Addressed the review on the latest branch head. The replacement test now uses an actually rejecting |
|
Updated the regression per your review: the replaced processor now returns a genuine rejected shutdown promise with no pre-attached handler. The replacement path contains it, logs the failure, and the replacement remains usable. Focused test passes. |
|
@codex review again |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
seratch
left a comment
There was a problem hiding this comment.
Thanks for updating the regression test. The genuine rejected shutdown promise addresses my previous feedback, and the runtime fix looks sound.
One existing fixture still needs updating: in packages/agents-core/test/tracing.test.ts, the test "should call all processors shutdown when setting new processors" assigns bare vi.fn() shutdown mocks. These return undefined, so the new .catch() call throws; coverage CI confirms this failure.
Please make both shutdown mocks return resolved promises, for example with vi.fn(async () => {}), and rerun the checks. This corrects the fixture to match the existing Promise<void> contract. No additional runtime fallback is needed.
|
Addressed in |
Summary
Handle rejected shutdown promises when replacing tracing processors.
MultiTracingProcessor.setProcessors()is synchronous but invokes each old processor's asyncshutdown()without observing its returned promise. If a custom processor rejects during shutdown, the rejection can surface as unhandled while the replacement processor list has already been installed.Keep the synchronous replacement contract, attach a rejection handler to each old-processor shutdown, and report failures through the existing redaction-aware tracing error logger. Replacement processors continue to be installed immediately.
Test plan
shutdown()returns a rejected promisemainIssue number
N/A. Found while auditing tracing processor replacement lifecycle.
Checks
pnpm testandpnpm test:examplespnpm test:integration.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PRpnpm changesetto indicate my changes