GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(provider): handle SSE reader cancel rejections by AlexanderWillner · Pull Request #44912 · anomalyco/opencode

Conversation

@AlexanderWillner

@AlexanderWillner AlexanderWillner commented Aug 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
AlexanderWillner added 2 commits August 25, 2026 09:19
@AlexanderWillner
fix(provider): catch SSE reader cancel rejection
456eac5
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.
@AlexanderWillner
test(pty): raise exit-poll deadline to 20s
70bf2f9
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.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the needs:issue label Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found.

The search identified several related but distinct PRs addressing different aspects of SSE stream handling (PRs #39970, #43607, #40010, #39516), but none of them are duplicates of PR #44912. This PR specifically addresses unhandled promise rejections from reader.cancel() under Bun 1.4, which is a distinct issue from prior SSE robustness improvements.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 25, 2026
@github-actions github-actions Bot closed this Aug 25, 2026
@github-actions github-actions Bot removed the needs:issue label Aug 25, 2026
@AlexanderWillner AlexanderWillner mentioned this pull request Aug 25, 2026
fix(provider): handle SSE reader cancel rejections #44944
Merged
3 tasks done
Bewinxed added a commit to Bewinxed/cawco that referenced this pull request Sep 30, 2026
@Bewinxed @claude
fix(agent): an opencode restart for a config apply leaves no unhandle…
07d7444
…d AbortError

#attemptConfigApply ends every directory's subscription (#stopPumps aborts
its owner controller) before it SIGTERMs the server. The opencode SDK's SSE
client answers that abort with `void reader.cancel()`
(@opencode-ai/sdk 1.18.18, dist/gen/core/serverSentEvents.gen.js:29,
createSseClient's abortHandler). The abort has already errored the fetch
body with the abort's reason, so under Bun 1.4 that cancel rejects with the
very AbortError #stopPumps created, and nothing observes it: every config
apply logged an unhandledRejection (stack abort <- #stopPumps <-
#attemptConfigApply), and a process without a handler went down.

The SDK is patched where the promise is made: the cancel is observed, a
rejection carrying the subscriber's own abort reason is the expected end of
that subscription, and any other rejection is rethrown, so it surfaces
exactly as before. Real connection errors reach the pump through
reader.read() as they always did. Both dist copies carry the handler, so
both are patched. 1.18.33, the latest release, still has the unobserved
cancel, so no upgrade fixes it (same defect: anomalyco/opencode#44912,
getpaseo/paseo#2027).

Repro: the real OpencodeHarness against an isolated opencode, restarted by
a config change. Before: an unhandled AbortError at the restart, then one
new subscription. After: none; the process survives, with one
subscription to the new server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

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)

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@AlexanderWillner
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.