Skip to content

Commit 16873f0

Browse files
fix: capture the pre-registration read and reload count on the reload queue
Reading the credential and noting the reload count as one step on the same serialized queue as the reloads means no reload can finish in between, so the count says exactly which reloads followed the read: overlapping repairs reload once and a stale read never skips a needed reload. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_016x3nbZU5Vb6HnSTqE7vELm
1 parent c16e521 commit 16873f0

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/opencode/src/server/server.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,14 @@ export namespace Server {
787787

788788
// Read before registering: a credential that was rejected, expired or logged out and is
789789
// now reissued with identical fields still has to reload, and only this read sees that.
790-
const before = await FreeTier.credentials().catch(() => undefined)
791-
// Snapshot after the read: a reload that finished during it must not count as covering
792-
// it. Erring this way costs at most one extra reload, never a stale directory.
793-
const generationAtStart = baseReloadGeneration
790+
// The read and the reload count are captured together on the reload queue, so no reload
791+
// can finish in between: the count says exactly which reloads came after this read.
792+
const snapshot = baseReloadQueue.then(async () => ({
793+
before: await FreeTier.credentials().catch(() => undefined),
794+
generationAtStart: baseReloadGeneration,
795+
}))
796+
baseReloadQueue = snapshot.catch(() => undefined)
797+
const { before, generationAtStart } = await snapshot
794798
const gate = FreeTierConsent.createRegistrationGate({
795799
register: () => FreeTier.register({ origin: "server" }),
796800
onUnexpectedError: (error) => log.error("Altimate Base registration failed", { error }),

0 commit comments

Comments
 (0)