Repository navigation
fix(core): recover wellknown sources and login plugin after startup outage - #53823
Open
kitlangton wants to merge 1 commit into
Open
kitlangton wants to merge 1 commit into
kitlangton wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
When OpenCode starts while a persisted
.well-known/opencodeorigin is unreachable, initial manifest discovery fails and leaveswellknown.snapshot()empty. Two cold-start paths then prevent recovery for the life of the process: the 10-minute config refresh loop exits early wheneverwellknown.snapshot()is empty instead of callingwellknown.refresh(), and the built-inopencode.wellknownplugin usesEffect.orDieon initial discovery before registering its integration transform or subscribing toWellKnown.Event.Updated. Because built-in plugins have a static"internal"revision, the plugin supervisor never retries the failed slot on later config reloads.What Changes
packages/core/src/config.ts): Always callswellknown.refresh()on the 10-minute timer so persisted origins in KV (wellknown:sources) are retried after a cold startup failure. Ifrefresh()reports no manifest change,reload()only runs whenwellknown.snapshot().length > 0.packages/core/src/wellknown/plugin.ts): Catches initialwellknown.entries()failures and logs a warning instead of dying during setup, allowing the plugin to register its integration transform and subscribe toWellKnown.Event.Updatedso login methods appear once discovery succeeds.sequenceDiagram participant KV as KV (wellknown:sources) participant P as WellKnownPlugin participant T as Config 10m Timer participant W as WellKnown.Service participant I as Integration.Service Note over P,W: Cold startup during manifest outage (503) P->>W: entries() W->>KV: get("wellknown:sources") W-->>P: Error (manifest unreachable) P->>I: register transform + subscribe(WellKnown.Event.Updated) Note over T,W: 10 minutes later (endpoint healthy) T->>W: refresh() W->>KV: get("wellknown:sources") W-->>P: publish WellKnown.Event.Updated P->>I: reload() -> registers "login" command methodDemo
pr-53823-v4.mp4
Scope
This PR owns cold-start recovery for the 10-minute well-known discovery timer and the built-in
opencode.wellknownplugin. Warm remote config caching and TUI session model retention are in separate PRs.Verification
test/config/wellknown-timer.test.ts: 2 tests pass (19 assertions) exercising the 10-minuteTestClockloop for both cold persisted sources and warm manifest outages.test/plugin/wellknown-recovery.test.ts: 1 test passes (7 assertions) verifying thatopencode.wellknownstays active across a cold discovery failure and registers thelogincommand when discovery recovers without a plugin revision change.