Skip to content

fix(agent): prevent unhandled rejection when aborting stream - #122

Open
warun7 wants to merge 1 commit into
OpenRouterTeam:mainfrom
warun7:fix/unhandled-rejection-on-stream-abort
Open

fix(agent): prevent unhandled rejection when aborting stream#122
warun7 wants to merge 1 commit into
OpenRouterTeam:mainfrom
warun7:fix/unhandled-rejection-on-stream-abort

Conversation

@warun7

@warun7 warun7 commented Sep 4, 2026

Copy link
Copy Markdown

Fixes #113

Summary of Changes

  • Attached a no-op rejection handler to executionPromise inside startTurnBroadcasterExecution() in packages/agent/src/lib/model-result.ts. This ensures that when a stream consumer aborts or terminates iteration early, the background promise rejection does not trigger an unhandledRejection event.
  • Added regression unit test in packages/agent/tests/unit/run-cancellation.test.ts.
  • Added changeset file for @openrouter/agent (patch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aborting a tool-enabled stream leaves executionPromise unhandled and can terminate Node.js

1 participant