Skip to content

Commit aba4bfe

Browse files
wlum0002-blipclaude
andcommitted
fix(server): Antigravity sign-in no longer blames the network while the runtime starts
The 30-second "has not reached Google" hint started before the ACP runtime was spawned. The one-file runtime unpacks itself on every launch, which takes about a minute on Windows before it answers initialize, so every Windows sign-in told the user to check their network or IPv6. Await the memoized initialize handshake first and time the hint from there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cefb544 commit aba4bfe

2 files changed

Lines changed: 58 additions & 14 deletions

File tree

‎apps/server/src/provider/AntigravityAuth.test.ts‎

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,21 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
8484
yield* Deferred.succeed(closed, undefined);
8585
}),
8686
);
87+
// Like AcpSessionRuntime, `start` reuses one memoized initialize handshake.
88+
const initialize = yield* Effect.cached(
89+
Effect.gen(function* () {
90+
events.push("initialize");
91+
yield* options.beforeInitialize ?? Effect.void;
92+
return options.supportsLogout === false
93+
? { ...initialized, agentCapabilities: {} }
94+
: initialized;
95+
}),
96+
);
8797
return {
88-
initialize: () =>
89-
Effect.gen(function* () {
90-
events.push("initialize");
91-
yield* options.beforeInitialize ?? Effect.void;
92-
return options.supportsLogout === false
93-
? { ...initialized, agentCapabilities: {} }
94-
: initialized;
95-
}),
98+
initialize: () => initialize,
9699
start: () =>
97100
Effect.gen(function* () {
101+
yield* initialize;
98102
events.push("authenticate");
99103
yield* Deferred.succeed(authenticateCalled, undefined);
100104
if (options.interactive !== false && input.onAuthorizationUrl) {
@@ -280,6 +284,42 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("AntigravityAuth"
280284
}),
281285
);
282286

287+
it.effect("does not blame the network while the runtime is still starting", () =>
288+
Effect.gen(function* () {
289+
const initializing = yield* Deferred.make<void>();
290+
const ready = yield* Deferred.make<void>();
291+
const harness = yield* makeHarness({
292+
interactive: false,
293+
beforeInitialize: Deferred.succeed(initializing, undefined).pipe(
294+
Effect.andThen(Deferred.await(ready)),
295+
),
296+
});
297+
const hasHint = harness.auth.controller.subscribe(owner).pipe(
298+
Stream.runHead,
299+
Effect.map((state) => Option.getOrThrow(state).message?.includes("Broken IPv6") === true),
300+
);
301+
yield* harness.auth.controller.start(owner);
302+
yield* Deferred.await(initializing);
303+
304+
// A one-file runtime can take about a minute to unpack before it answers initialize.
305+
yield* TestClock.adjust("60 seconds");
306+
assert.isFalse(yield* hasHint);
307+
308+
yield* Deferred.succeed(ready, undefined);
309+
yield* Deferred.await(harness.authenticateCalled);
310+
yield* TestClock.adjust("29 seconds");
311+
assert.isFalse(yield* hasHint);
312+
313+
yield* TestClock.adjust("1 second");
314+
const stalled = yield* harness.auth.controller.subscribe(owner).pipe(
315+
Stream.filter((state) => state.message?.includes("Broken IPv6") === true),
316+
Stream.runHead,
317+
Effect.map(Option.getOrThrow),
318+
);
319+
assert.equal(stalled.phase, "starting");
320+
}),
321+
);
322+
283323
it.effect("keeps the expired message once the Google link was shown", () =>
284324
Effect.gen(function* () {
285325
const harness = yield* makeHarness();
@@ -385,7 +425,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("AntigravityAuth"
385425
assert.isTrue(Exit.isFailure(competing));
386426
const resumed = yield* phase(harness.auth, "waiting");
387427
assert.equal(resumed.flowId, first.flowId);
388-
assert.deepEqual(harness.events, ["process-open", "authenticate"]);
428+
assert.deepEqual(harness.events, ["process-open", "initialize", "authenticate"]);
389429
yield* harness.auth.controller.cancel(owner, first.flowId!);
390430
}),
391431
);

‎apps/server/src/provider/AntigravityAuth.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ import {
3131
import type { ProviderAuthController } from "./ProviderAuthService.ts";
3232

3333
const AUTH_TIMEOUT_MS = 300_000;
34-
// A healthy agent shows the Google link or finishes within seconds. Its bundled Python has no
35-
// IPv4 fallback race, so a host with broken IPv6 waits about two minutes per Google request.
34+
// Once initialized, a healthy agent shows the Google link or finishes within seconds. Its bundled
35+
// Python has no IPv4 fallback race, so a host with broken IPv6 waits about two minutes per Google
36+
// request. The hint is timed from initialize, not spawn: the one-file runtime unpacks itself on
37+
// every launch, which can take about a minute on Windows before it answers at all.
3638
const NO_RESPONSE_HINT_MS = 30_000;
3739
const NO_RESPONSE_MESSAGE =
3840
"Antigravity has not reached Google after 30 seconds. Check this machine's network connection. Broken IPv6 is a common cause.";
@@ -271,6 +273,11 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
271273
const runSignIn = Effect.fn("AntigravityAuth.runSignIn")(
272274
function* (flow: AuthFlow, stopSessions: Effect.Effect<void, ProviderSetupError>) {
273275
yield* stopSessions.pipe(Effect.ensuring(stopOwnedProcesses));
276+
const runtime = yield* options.makeRuntime({
277+
onAuthorizationUrl: (url) => receiveAuthorizationUrl(flow, url),
278+
});
279+
// `start` reuses this memoized handshake.
280+
yield* runtime.initialize();
274281
yield* Effect.sleep(NO_RESPONSE_HINT_MS).pipe(
275282
Effect.andThen(
276283
lock.withPermits(1)(
@@ -282,9 +289,6 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
282289
),
283290
Effect.forkScoped,
284291
);
285-
const runtime = yield* options.makeRuntime({
286-
onAuthorizationUrl: (url) => receiveAuthorizationUrl(flow, url),
287-
});
288292
const started = yield* runtime.start();
289293
yield* lock.withPermits(1)(
290294
Effect.gen(function* () {

0 commit comments

Comments
 (0)