Skip to content

fix(core): keep healthy well-known origins when one is unreachable - #46188

Closed
ryanskidmore wants to merge 1 commit into
anomalyco:v2from
ryanskidmore:wellknown-origin-tolerance
Closed

ryanskidmore wants to merge 1 commit into
anomalyco:v2from
ryanskidmore:wellknown-origin-tolerance

Conversation

@ryanskidmore

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #46187

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

WellKnown.load() resolved origins with a fail-fast Effect.forEach, so one unreachable origin failed the whole batch. The wellknown plugin called it through Effect.orDie, so that failure killed the plugin before it registered its transform — and every well-known integration disappeared, not just the dead one. Config.loadWellknown catches the same failure and returns [], so the remote config for the healthy origins went with it.

Each origin is now resolved independently. If one fails we keep its last known manifest, or skip it when nothing is cached. refresh() goes through the same path, so a temporary outage falls back to the cache and correctly reports "no change" instead of failing.

I also swapped the plugin's orDie for a logged catch. Worth noting it has to catch and continue — simply deleting orDie isn't enough, because yield* would still short-circuit before ctx.integration.transform(...) and the symptom would be unchanged.

The confusing part of the original bug is that auth login <url> prints "Authentication provider discovered" and then "Integration not found" for the same URL. Those come from different paths: wellknown.add only fetches the one origin you passed, so it genuinely succeeds, and the lookup afterwards reads a registry the dead plugin never populated.

It also only appears after a restart, since load() reuses the in-memory cache — which makes it look like whichever version you just installed broke it.

How did you verify your code works?

Two tests in packages/core/test/wellknown.test.ts, both of which fail on v2 and pass with this change (I checked by stashing the src/ changes and re-running):

  • a closed port listed alongside a live fixture server — entries() returns only the live origin
  • an origin that goes away after being loaded — refresh() returns false and keeps the manifest

From packages/core: bun run test test/wellknown.test.ts (5 pass) and bun run test test/config/config.test.ts (35 pass), plus bun typecheck.

I also reproduced the original failure end-to-end with the installed 0.0.0-beta-18684 client against packages/core/script/wellknown-server.ts: adding an unresolvable origin to wellknown:sources makes auth login fail for a healthy origin, and removing it fixes it.

Not in this PR, but related: WellKnown.remove() exists and nothing reaches it — no route and no CLI — so wellknown:sources only ever grows and the only way out of this state today is editing SQLite by hand. Happy to follow up if you want that exposed.

Screenshots / recordings

Not a UI change.

Checklist

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

@github-actions

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.

@github-actions

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant