Uh oh!
There was an error while loading. Please reload this page.
fix(provider): handle SSE reader cancel rejections - #44944
Open
AlexanderWillner wants to merge 2 commits into
Open
fix(provider): handle SSE reader cancel rejections#44944AlexanderWillner wants to merge 2 commits into
AlexanderWillner wants to merge 2 commits into
Conversation
When the chunk-timeout fires, the fetch-body reader is cancelled after the request signal is aborted. Under Bun 1.4 reader.cancel() then rejects, and the voided promise surfaces as an unhandled rejection that fails tests (and can crash strict runtimes). Handle the rejection explicitly.
The 5s deadline is load-sensitive: under a fully parallel test run the PTY exit event was observed too late and the test failed even though the behaviour under test is correct.
3 tasks
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 freeto 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.
Issue for this PR
Closes#44943
Type of change
What does this PR do?
When the SSE chunk-timeout fires, the fetch-body reader is cancelled after the request signal is aborted. Under Bun 1.4 reader.cancel() then rejects and the voided promise surfaces as an unhandled rejection, which fails the running test even though its assertions passed. This handles the cancellation explicitly in both wrapSSE implementations (packages/opencode/src/provider/provider.ts, packages/core/src/aisdk.ts).
Also relaxes one PTY test's exit-poll deadline from 5s to 20s: under a fully parallel suite run the PTY exit event was observed at ~5.3s, so the poll deadline was exceeded despite correct behaviour. Assertion unchanged.
(Supersedes #44912, which was auto-closed before I could fix the template.)
How did you verify your code works?
Full suite from packages/opencode under Bun 1.4.0 and Bun 1.3.14: 3339 tests, 0 fail with these changes (before: one deterministic failure under 1.4.0, one load-dependent PTY failure). tsgo typecheck clean. darwin-arm64 binaries built with both runtimes, smoke tests pass.
Checklist