Skip to content

Commit c2f1891

Browse files
fix(provider-core): recheck a failed sign-in when settings are applied
A provider whose last probe was unauthenticated kept that error after the credential was fixed, because an unrelated settings apply returned the cached snapshot. Treat any settings apply as a recheck while the snapshot is unauthenticated. Fixes #34295 AI-assisted; verified with the tests and tools listed above.
1 parent dcf4ce6 commit c2f1891

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/provider-core/src/server/managedProvider.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,15 @@ export const makeManagedServerProvider = Effect.fn("makeManagedServerProvider")(
143143
nextSettings: Settings,
144144
options?: { readonly forceRefresh?: boolean },
145145
) {
146-
const forceRefresh = options?.forceRefresh === true;
147146
const previousSettings = yield* Ref.get(settingsRef);
148-
if (!forceRefresh && !input.haveSettingsChanged(previousSettings, nextSettings)) {
147+
const settingsChanged =
148+
options?.forceRefresh === true || input.haveSettingsChanged(previousSettings, nextSettings);
149+
// Nothing watches credential files, so any settings apply rechecks a failed sign-in.
150+
const { snapshot: currentSnapshot } = yield* Ref.get(snapshotStateRef);
151+
const forceRefresh =
152+
options?.forceRefresh === true ||
153+
(currentSnapshot.enabled && currentSnapshot.auth.status === "unauthenticated");
154+
if (!forceRefresh && !settingsChanged) {
149155
yield* Ref.set(settingsRef, nextSettings);
150156
return yield* Ref.get(snapshotStateRef).pipe(Effect.map((state) => state.snapshot));
151157
}

0 commit comments

Comments
 (0)