fix(web): a rejected desktop-local credential is not retried every poll #16273
Mergedjuliusmarmingemerged 8 commits into
main fromrefs/pull/16273/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- packages/client-runtime/src/connection/registry.ts line 665OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -654,5 +655,11 @@654655 // on their own loopback origin, so they authenticate with a bearer655656 // token instead of the primary's same-origin cookie. Stash it where656657 // the resolver's bearer broker looks it up.658+ let bearerReplaced = false;657659 if (registration._tag === "BearerConnectionRegistration") {660+ const stored = yield* credentials661+ .get(registration.target.connectionId)662+ .pipe(Effect.orElseSucceed(() => Option.none<ConnectionCredential>()));663+ bearerReplaced =664+ Option.isSome(stored) && !Equal.equals(stored.value, registration.credential);658665 yield* credentials.put(registration.target.connectionId, registration.credential).pipe(
- @@ -654,4 +655,10 @@654655 // on their own loopback origin, so they authenticate with a bearer655656 // token instead of the primary's same-origin cookie. Stash it where656657 // the resolver's bearer broker looks it up.658+ let bearerReplaced = false;657659 if (registration._tag === "BearerConnectionRegistration") {660+ const stored = yield* credentials661+ .get(registration.target.connectionId)662+ .pipe(Effect.orElseSucceed(() => Option.none<ConnectionCredential>()));663+ bearerReplaced =664+ Option.isSome(stored) && !Equal.equals(stored.value, registration.credential);packages/client-runtime/src/connection/registry.ts lines 707 to 709OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -687,3 +694,16 @@687694 }688695689696 yield* installEntryLocked(entry, { retainEquivalentRuntime: true });697+698+ // The catalog entry carries no credential, so a fresh bearer keeps699+ // the equivalent runtime. A supervisor that stopped on the old700+ // bearer's authentication failure would otherwise wait for a manual701+ // retry, so wake it with the new one.702+ if (bearerReplaced) {703+ const scope = (yield* SubscriptionRef.get(serviceScopes)).get(target.environmentId);704+ if (scope !== undefined) {705+ const state = yield* SubscriptionRef.get(scope.supervisor.state);706+ if (707+ state.phase === "blocked" &&708+ state.lastFailure?._tag === "ConnectionBlockedError" &&709+ state.lastFailure.reason === "authentication"
- apps/web/src/connection/platform.ts line 687Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -602,7 +667,21 @@667+ if (668+ cached !== undefined &&669+ canRetainCachedPlatformRegistrationAfterRefreshFailure(670+ cached,671+ endpointSignature,672+ nowEpochMs,673+ )674+ ) {675+ next.set(bootstrap.id, cached);676+ registrations.push(cached.registration);677+ }678+ continue;679+ }602680 const built = yield* loadSecondaryConnectionRegistration(bootstrap).pipe(603681 Effect.tapError((error) =>604682 Effect.logWarning("Could not connect a desktop-local backend.", {605683 id: bootstrap.id,606684 error,607685 }),608686 ),687+ Effect.tapError((error) =>
juliusmarminge merged thisf36df18
juliusmarminge closed this
Sign in to join this conversation.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This PR changes desktop-local bearer credential storage, token exchange backoff, cache retention, and supervisor retry behavior on a production authentication path. An unresolved read/write failure scenario can prevent a blocked connection from retrying after its credential is replaced, so the state transitions and recovery behavior need human review.
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).