0a4d8746f9
Gemini CLI / Antigravity OAuth login could hang indefinitely during Cloud Code Assist provisioning: pollOperation was an unbounded while(true) loop with bare fetch calls that never checked OAuthController.signal, passed no signal to fetch, and had no per-request timeout or attempt cap. Add a shared oauthFetch helper that composes the controller signal with a 30s per-request timeout, and a throwIfLoginCancelled guard. Thread the signal through exchangeToken, getUserEmail, discoverProject, onboardUser, pollOperation, and the Antigravity onboardProjectWithRetries/discoverProject. Bound pollOperation to 24 attempts; a stall now surfaces OAuthError (kind:"timeout") and cancellation surfaces LoginCancelledError. Fixes #4085
25 lines
806 B
TypeScript
25 lines
806 B
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { GoogleOAuthFlow } from "../src/registry/oauth/google-oauth-shared";
|
|
import type { OAuthController } from "../src/registry/oauth/types";
|
|
|
|
describe("GoogleOAuthFlow callback hostname", () => {
|
|
it("uses 127.0.0.1 as the callback hostname to avoid IPv6 and proxy delays", () => {
|
|
const ctrl: OAuthController = {
|
|
onAuth: () => {},
|
|
};
|
|
const flow = new GoogleOAuthFlow(ctrl, {
|
|
provider: "google-gemini-cli",
|
|
clientId: "test-client",
|
|
clientSecret: "test-secret",
|
|
authUrl: "https://example.com/auth",
|
|
tokenUrl: "https://example.com/token",
|
|
scopes: ["scope1"],
|
|
callbackPort: 51121,
|
|
callbackPath: "/callback",
|
|
discoverProject: async () => "test-project",
|
|
});
|
|
|
|
expect(flow.callbackHostname).toBe("127.0.0.1");
|
|
});
|
|
});
|