fix(clients): reconnect after credentials fail during remote server updates (#7953)
This commit is contained in:
1 parent
fdd1572b69
commit
afa8309806
2 files changed
+40
-2
No files matched your search
@@ -124,6 +124,30 @@ describe("update restart reconnect nudges", () => {
|
||||
yield* Fiber.join(fiber);
|
||||
}).pipe(Effect.provide(TestClock.layer())),
|
||||
);
|
||||
|
||||
it.effect("retries rejected credentials only while the update restart is in progress", () =>
|
||||
Effect.gen(function* () {
|
||||
const retries = yield* Ref.make(0);
|
||||
|
||||
yield* nudgeReconnectDuringUpdateRestart({
|
||||
stateChanges: Stream.fromIterable([
|
||||
{ phase: "blocked", lastFailure: { reason: "permission" } },
|
||||
{
|
||||
phase: "blocked",
|
||||
lastFailure: {
|
||||
reason: "authentication",
|
||||
detail: "The environment credential is invalid.",
|
||||
},
|
||||
},
|
||||
{ phase: "blocked", lastFailure: { reason: "configuration" } },
|
||||
]),
|
||||
retryNow: Ref.update(retries, (count) => count + 1),
|
||||
interval: Duration.zero,
|
||||
});
|
||||
|
||||
expect(yield* Ref.get(retries)).toBe(1);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
describe("server state projection", () => {
|
||||
|
||||
@@ -160,16 +160,30 @@ export function validateServerUpdateReadyEvent(
|
||||
* each nudge is the pacer: a connection that fails instantly re-enters backoff
|
||||
* immediately and would otherwise spin a tight retry loop.
|
||||
*
|
||||
* A newly restarted server can also reject the first environment credential.
|
||||
* Authentication blocks need the same paced retry during this known restart;
|
||||
* permission and configuration failures remain blocked.
|
||||
*
|
||||
* Callers fork this as a child of the update command so it is interrupted as
|
||||
* soon as the update settles, whether it succeeds, fails, or times out.
|
||||
*/
|
||||
export function nudgeReconnectDuringUpdateRestart(input: {
|
||||
readonly stateChanges: Stream.Stream<{ readonly phase: string }, unknown>;
|
||||
readonly stateChanges: Stream.Stream<
|
||||
{
|
||||
readonly phase: string;
|
||||
readonly lastFailure?: { readonly reason: string } | null;
|
||||
},
|
||||
unknown
|
||||
>;
|
||||
readonly retryNow: Effect.Effect<void>;
|
||||
readonly interval?: Duration.Duration;
|
||||
}): Effect.Effect<void> {
|
||||
return input.stateChanges.pipe(
|
||||
Stream.filter((state) => state.phase === "backoff"),
|
||||
Stream.filter(
|
||||
(state) =>
|
||||
state.phase === "backoff" ||
|
||||
(state.phase === "blocked" && state.lastFailure?.reason === "authentication"),
|
||||
),
|
||||
Stream.runForEach(() =>
|
||||
Effect.sleep(input.interval ?? Duration.seconds(1)).pipe(Effect.andThen(input.retryNow)),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user