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(core): resolve coherent state before OAuth refresh by kitlangton · Pull Request #45810 · anomalyco/opencode

Conversation

@kitlangton

@kitlangton kitlangton commented Aug 28, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Why

Plugin setup runs inside State.batch, which defers registration publication. Console registers its OAuth refresh implementation and then resolves its connection during that same setup. The resolver can therefore miss the handler and return an expired token unchanged.

The earlier version of this PR added State.flush(), but its pending-work check could return while another fiber was still rebuilding. This revision makes obtaining the coherent value one synchronized operation instead.

What Changes

Operation Contract
state.get() Return the last published value immediately, without rebuilding or waiting. Unchanged.
state.resolve() Materialize completed registration/disposal changes or join an in-progress rebuild, then return the published value.
state.reload() Keep the existing debounced replay behavior. Resolution does not wait out a scheduled reload's debounce.

Integration.connection.resolve uses the returned value to find its OAuth refresh implementation:

const current = yield* state.resolve()
const implementation = current.integrations
  .get(credential.integrationID)
  ?.implementations.get(credential.value.methodID)

Other State reads remain unchanged. There is no caller-visible State.flush() or plugin-activation wait on this path.

Publication Ordering

The existing State semaphore owns the pending-work decision, rebuild, and returned value. Pending registrations become clean only when the replacement value is published, so a failed replay remains resolvable. Successful resolution absorbs the current batch's queued rebuild.

Waiting for the semaphore remains interruptible. Once resolution starts rebuilding, publication and notification finish together before interruption propagates. OAuth network refresh runs after State resolution has released the semaphore.

sequenceDiagram
    participant P as Plugin setup
    participant I as Integration resolver
    participant S as State
    participant O as OAuth provider
    P->>S: Register refresh implementation inside batch
    P->>I: Resolve stored connection
    I->>S: resolve()
    S->>S: Join or rebuild under semaphore
    S-->>I: Published registry; semaphore released
    I->>O: Refresh expired credential
    O-->>I: Fresh credential
    I-->>P: Persisted fresh credential
Loading

Scope

This owns State registration visibility and the OAuth refresh-handler lookup, not plugin installation, cross-registry transactions, or Console inventory recovery. It retains nonblocking discovery reads and does not change the broader activation policy. #45759 can remove its plugin-side registration-visibility workaround after this lands.

Verification

Run with Bun 1.4.0 from packages/core:

bun run test test/state.test.ts test/integration.test.ts
bun run test test/state.test.ts \
  --test-name-pattern 'concurrent resolution|queued resolution|replay fails' \
  --rerun-each 100
bun typecheck
bun run test
  • Focused State/Integration suites: 27 passed.
  • Full Core suite: 4,071 passed, 40 skipped, 0 failed across 230 files. The focused suites passed again after strengthening the existing reload test.
  • New concurrency, cancellation, and failed-replay regressions: 300 passed across 100 repetitions each. All three failed against the previous synchronization before the fix.
  • Coverage retains same-batch expired OAuth refresh and persistence, registration/disposal visibility, no duplicate batch rebuild, nonblocking published reads, reload debounce, and teardown suppression.
  • Core typechecking, changed-file formatting, and whitespace checks passed.
  • The unmodified pre-push hook passed all 33 repository typecheck tasks.

Sorry, something went wrong.

Uh oh!

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

All reactions
@github-actions github-actions Bot added the contributor label Aug 28, 2026
@kitlangton kitlangton mentioned this pull request Aug 28, 2026
fix(core): pull pending registry changes on read #45822
Closed
kitlangton added 2 commits September 1, 2026 10:22
@kitlangton
fix(core): refresh OAuth credentials during batched activation
b9cd9e3
@kitlangton
fix(core): resolve coherent state before OAuth refresh
911a399
@kitlangton kitlangton changed the title fix(core): refresh OAuth credentials during batched activation fix(core): resolve coherent state before OAuth refresh Sep 1, 2026
@kitlangton
kitlangton force-pushed the state-flush branch from 9545bb3 to 911a399 Compare September 1, 2026 14:40
This was referenced Sep 1, 2026
test(core): reproduce OAuth refresh omission during batching #46616
Closed
fix(core): rebuild registry state on read #46631
Closed
fix(core): rebuild registry state on read #46725
Closed
fix(core): rebuild registry state on read #46825
Merged
@github-actions

github-actions Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot closed this Sep 28, 2026
@github-actions github-actions Bot added the automated-pr-cleanup label Sep 28, 2026
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

automated-pr-cleanup contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

1 participant

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