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(plugin): honor abort signals in Promise plugin API calls by vimtor · Pull Request #65980 · anomalyco/opencode

Conversation

@vimtor

@vimtor vimtor commented Nov 24, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

What broke

Promise plugins ignored the signal they passed to the API methods on ctx. Those methods are typed with the SDK's request options. For example, ctx.experimental.automation.delete accepts { signal }. But the Promise adapter's wrapper (adaptApiMethod in packages/plugin/src/promise/adapter.ts) only read the first argument. So a call with an already-aborted signal still ran: automation.delete resolved and removed the automation. Over HTTP, the SDK passes the signal to fetch, which rejects right away.

This affects Promise plugin authors who cancel calls with an AbortController. The automation methods came in with #65747, which exposed create/list/delete to Promise plugins through this wrapper.

Trigger: create an automation, abort a controller, then call ctx.experimental.automation.delete({ automationID }, { signal: controller.signal }). The call resolves and the automation is gone.

Fix

adaptApiMethod now takes the second options argument:

  • If the signal is already aborted, the call rejects with signal.reason and the Effect never runs. A pre-check is needed because Effect.runPromiseWith runs the effect synchronously before it looks at the signal. Passing the signal on its own still let the delete complete (I tested that).
  • Otherwise the signal is passed to Effect.runPromiseWith, so aborting it later interrupts the call.

This is in the shared wrapper, so every adapted Promise API method now handles the signal, not just automation.

Test

packages/core/test/plugin/automation.test.ts: "Promise plugins cannot delete an automation with an aborted signal". It expects the call to reject and the automation to still be listed.

Before the fix:

error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at setup (packages/core/test/plugin/automation.test.ts:94:19)
(fail) Promise plugins cannot delete an automation with an aborted signal

After the fix, all of packages/core/test/plugin (679 tests) and the packages/plugin tests pass, and bun run check is green.

Found by the daily review job.


Added by the opencode bot (AI-generated).

Fixes #57135

Public API: Promise plugin API methods on ctx now honour the signal in their request options (no type changes, backwards compatible)

Sorry, something went wrong.

Uh oh!

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

All reactions
@vimtor
fix(plugin): honor abort signals in Promise plugin API calls
8d2d674
@github-actions github-actions Bot added the contributor label Nov 24, 2026
@vimtor
vimtor marked this pull request as ready for review November 24, 2026 08:57
@vimtor
vimtor enabled auto-merge (squash) November 24, 2026 08:58
opencodejr[bot]
opencodejr Bot reviewed Nov 24, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works. A Promise plugin's API calls on ctx now honour the signal they're given. I checked it two ways:

  • The new test fails on the base and passes with this change.
  • I ran the reproduction from #57135 through opencode-drive: ctx.generate.text with a signal aborted after 1s, against a simulated model that answers after 6s. On the base the call resolved after about 6s. With this PR it rejected at about 1s.

The pre-check is needed: Effect's runForkWith runs the effect before it looks at signal.aborted. packages/plugin tests pass. The test/plugin failures in packages/core are the same GitLab OAuth ones as on the base. tsc is clean for both packages.

Public API: no types change, since the methods were already typed with request options that include signal. Plugins that passed a signal will now see the call stop. Callers that don't pass one are unaffected.

Concerns:

  • What the call rejects with depends on when the signal is aborted (inline comment).
  • Out of scope, possible follow-up: ctx.rpc clients in the same file (rpcFromEffect) pass the signal to the runner but have the same gap when it's already aborted, so the call still runs.

Fixes #57135

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/plugin/src/promise/adapter.ts
}).pipe(Effect.runPromiseWith(runtime))) as PromiseMethod
return ((input?: unknown, options?: { readonly signal?: AbortSignal }) => {
// The runner evaluates synchronously before it checks the signal, so an aborted call could start a mutation.
if (options?.signal?.aborted) return Promise.reject(options.signal.reason)

@opencodejr opencodejr Bot Nov 24, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What the call rejects with depends on when the signal is aborted:

  • Aborted before the call: it rejects with signal.reason, an AbortError, like fetch.
  • Aborted during the call: Effect interrupts the fiber and the promise rejects with a generic Error: All fibers interrupted without error. I saw this in a real run with ctx.generate.text.

Plugins that check error.name === "AbortError", as they would over HTTP, will miss the second case. Could the run reject with options.signal.reason whenever the signal is aborted? For example, add .catch((error) => Promise.reject(options?.signal?.aborted ? options.signal.reason : error)) to the run.

Sorry, something went wrong.

Uh oh!

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

All reactions
@vimtor
vimtor merged commit 57f83d6 into dev Nov 24, 2026
21 checks passed

Uh oh!

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

@vimtor
vimtor deleted the fix-automation-abort branch November 24, 2026 09:04
@vimtor vimtor mentioned this pull request Nov 24, 2026
fix(plugin): reject aborted Promise plugin calls with the signal's reason #66041
Merged
@kelos-bot kelos-bot Bot mentioned this pull request Nov 24, 2026
[kanon-fake-strategist] Render hooks per agent capability and add OpenCode hook support kelos-dev/kanon#100
Open
This was referenced Nov 24, 2026
fix(core): register worktrees before honoring cancellation #66105
Merged
chore(core): revert niche fixes from the daily review job #66140
Merged
@B-icy B-icy mentioned this pull request Nov 25, 2026
Stage runtime v22 with three upstream OpenCode fixes B-icy/Carthagent#327
Merged
B-icy added a commit to B-icy/Carthagent that referenced this pull request Nov 25, 2026
@B-icy @factory-droid
Reuse runtime patch section parser after review
633d672
Share the existing validated parser between the first-use and v22
patch tests without changing the staged runtime bytes.

Upstream: anomalyco/opencode#65980

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@simonklee simonklee mentioned this pull request Nov 25, 2026
fix(cli-rs): bring the Rust client level with the TUI #66470
Merged
@amrkmn amrkmn mentioned this pull request Nov 26, 2026
opencode 2.4.2 amrkmn/homebrew-tap#1260
Closed
1 task
This was referenced Nov 26, 2026
feat: opencode release v2.4.2 sprisa/opencode-server#97
Merged
Tool release: OpenCode 2 v2.4.2 (was v2.3.2) agent-sh/agnix#1894
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

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

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

v2: plugin ctx.generate.text ignores the abort signal, so a cancelled generation keeps running

Uh oh!

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

1 participant

@vimtor
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.