Skip to content

fix(provider): handle SSE reader cancel rejections - #44944

Open
AlexanderWillner wants to merge 2 commits into
anomalyco:devfrom
AlexanderWillner:bun14-robustness
Open

fix(provider): handle SSE reader cancel rejections#44944
AlexanderWillner wants to merge 2 commits into
anomalyco:devfrom
AlexanderWillner:bun14-robustness

Conversation

@AlexanderWillner

Copy link
Copy Markdown

Issue for this PR

Closes#44943

Type of change

  • Bug fix

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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.
Sign up for freeto 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.

provider: unhandled rejection when SSE chunk-timeout cancels the fetch reader (suite red under Bun 1.4)

1 participant

@AlexanderWillner