Skip to content

fix: handle source errors during stream cancellation - #617

Open
embrace897 wants to merge 1 commit into
OpenRouterTeam:mainfrom
embrace897:codex/handle-stream-cancel-errors
Open

embrace897 wants to merge 1 commit into
OpenRouterTeam:mainfrom
embrace897:codex/handle-stream-cancel-errors

Conversation

@embrace897

Copy link
Copy Markdown

Fixes #615

Summary

  • return the source reader's cancellation promise from the stream wrapper
  • absorb source cancellation failures so they do not become unhandled rejections
  • add a regression test for cancellation after an AbortError
  • add a patch changeset

Why

When the underlying fetch stream has already errored, reader.cancel() can
reject. The wrapper previously ignored that promise, allowing the rejection to
surface as an unhandled AbortError and potentially terminate the host process.

Testing

  • issue regression test: passed
  • existing withStreamErrorHandling tests: 6 passed
  • TypeScript typecheck: passed
  • Biome check: passed
  • git diff --check: passed

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.

Unhandled AbortError when a cancelled stream has already errored

1 participant