Skip to content

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

Closed

Description

@AlexanderWillner

Found while running the packages/opencode suite under Bun 1.4.0 (bun@1.3.14 passes).

Both SSE chunk-timeout wrappers (packages/opencode/src/provider/provider.ts and packages/core/src/aisdk.ts) do on timeout:

ctl.abort(err)
void reader.cancel(err)
reject(err)

Under Bun 1.4, reader.cancel() on the just-aborted fetch body rejects, leaving an unhandled promise rejection. In bun test this fails the running test even though its assertions passed:

(fail) chunkTimeout raises a response stream error when SSE body stalls

Raw stream semantics (read/timeout race, rejected pull) behave identically on 1.3.14 and 1.4.0 in isolation, so the failure only materialises through the full fetch → wrapSSE → ai-sdk path.

Fix direction: handle the cancellation result (reader.cancel(err).catch(() => {})). With that plus relaxing one load-sensitive PTY poll deadline, the full suite is green under both runtimes (3339 tests, 0 fail each).

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions