The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 22:00 UTC
fix(server): preserve antigravity ipv6 startup diagnostics (#15629)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
maria committed
Oct 20, 2026 at 05:06 UTC
9f01c5846cda2aab60bf7ca5b9ebbf331099ee62
8 files changed
+125
-20
apps/server/src/provider/AntigravityInstallation.test.ts
+48
@@ -18,6 +18,7 @@ import * as Sink from "effect/Sink";
18
import * as Stream from "effect/Stream";
19
import * as TestClock from "effect/testing/TestClock";
20
import { HttpClient, HttpClientResponse } from "effect/http";
21
+import * as ChildProcess from "effect/process/ChildProcess";
22
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
23
24
import * as AntigravityInstallation from "./AntigravityInstallation.ts";
@@ -553,6 +554,53 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
554
}),
555
);
556
557
+ it.effect.each([
558
+ {
559
+ name: "IPv6 startup failure",
560
+ stderr:
561
+ "enforce_kernel_ipv6_support.cc:70] Check failed: AddressFamilySupported(AF_INET6, &loopback6_ok)",
562
+ message:
563
+ "Antigravity requires IPv6 socket support. Enable IPv6 in this environment. On WSL, remove ipv6.disable=1 from .wslconfig and run wsl --shutdown.",
564
+ },
565
+ {
566
+ name: "other startup failure",
567
+ stderr: "Private startup diagnostics: internal runtime failure",
568
+ message: "The downloaded Antigravity runtime could not start in this environment.",
569
+ },
570
+ ])(
571
+ "reports a fixed diagnostic for $name and preserves the previous release after SIGABRT",
572
+ (testCase) =>
573
+ Effect.gen(function* () {
574
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
575
+ const { installation, stagingReleased } = yield* makeHarness({
576
+ previous: true,
577
+ useDefaultValidation: true,
578
+ }).pipe(
579
+ Effect.provideService(
580
+ ChildProcessSpawner.ChildProcessSpawner,
581
+ ChildProcessSpawner.make((command) =>
582
+ spawner.spawn(
583
+ command._tag === "StandardCommand" && command.command.endsWith(executableName)
584
+ ? ChildProcess.make(process.execPath, [
585
+ "-e",
586
+ `process.stderr.write(${encodeJsonString(testCase.stderr)}, () => process.kill(process.pid, 'SIGABRT'));`,
587
+ ])
588
+ : command,
589
+ ),
590
+ ),
591
+ ),
592
+ );
593
+ yield* installation.start;
594
+ expect(yield* terminalState(installation)).toMatchObject({
595
+ phase: "failed",
596
+ message: testCase.message,
597
+ });
598
+ yield* Deferred.await(stagingReleased);
599
+ yield* expectPreviousRelease(installation);
600
+ }),
601
+ { skip: hostPlatform === "win32" },
602
+ );
603
+
604
it.effect("accepts an encoded Content-Length when the body is compressed", () =>
605
Effect.gen(function* () {
606
// dl.google.com gzips the archive and reports the encoded size. The decoded
apps/server/src/provider/AntigravityInstallation.ts
+11
-6
@@ -24,6 +24,7 @@ import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
24
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
25
import * as NodeCrypto from "node:crypto";
26
import * as NodeFSP from "node:fs/promises";
27
+import * as EffectAcpErrors from "effect-acp/errors";
28
29
import * as ServerConfig from "../config.ts";
30
import { openZipArchive } from "../zipArchive.ts";
@@ -69,6 +70,7 @@ export class AntigravityInstallationError extends Schema.TaggedError<Antigravity
70
}
71
}
72
const isInstallationError = Schema.is(AntigravityInstallationError);
73
+const isAcpProcessExitedError = Schema.is(EffectAcpErrors.AcpProcessExitedError);
74
75
export interface AntigravityExecutable {
76
readonly executablePath: string;
@@ -423,12 +425,15 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
425
Effect.provideService(Path.Path, path),
426
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
427
Effect.provideService(Crypto.Crypto, crypto),
426
- Effect.mapError(
427
- wrapFailure(
428
- "verify",
429
- "The downloaded Antigravity runtime could not start in this environment.",
430
- ),
431
- ),
428
+ Effect.mapError((cause) => {
429
+ if (isInstallationError(cause)) return cause;
430
+ const detail =
431
+ isAcpProcessExitedError(cause) &&
432
+ /\b(?:AF_INET6|enforce_kernel_ipv6_support)\b/.test(cause.stderr ?? "")
433
+ ? "Antigravity requires IPv6 socket support. Enable IPv6 in this environment. On WSL, remove ipv6.disable=1 from .wslconfig and run wsl --shutdown."
434
+ : "The downloaded Antigravity runtime could not start in this environment.";
435
+ return installationError("verify", detail, cause);
436
+ }),
437
);
438
439
const install = Effect.fn("AntigravityInstallation.install")(
apps/server/src/provider/acp/AcpJsonRpcConnection.test.ts
+36
-7
@@ -5,7 +5,8 @@ import * as NodeURL from "node:url";
5
import * as NodeFS from "node:fs";
6
7
import * as NodeServices from "@effect/platform-node/NodeServices";
8
-import { it } from "@effect/vitest";
8
+import { assert, it } from "@effect/vitest";
9
+import * as HostProcess from "@t3tools/shared/HostProcess";
10
import * as Deferred from "effect/Deferred";
11
import * as Effect from "effect/Effect";
12
import * as Exit from "effect/Exit";
@@ -376,7 +377,19 @@ describe("AcpSessionRuntime", () => {
377
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
378
);
379
379
- it.effect("attaches child stderr when the ACP process exits before initialize", () =>
380
+ it.effect.each([
381
+ { name: "exit code", terminate: "process.exit(1)", code: 1, signal: undefined },
382
+ ...(HostProcess.Platform.defaultValue() === "win32"
383
+ ? []
384
+ : [
385
+ {
386
+ name: "signal",
387
+ terminate: "process.kill(process.pid, 'SIGTERM')",
388
+ code: undefined,
389
+ signal: "SIGTERM",
390
+ },
391
+ ]),
392
+ ])("retains the $name and sanitized stderr when ACP exits before initialize", (testCase) =>
393
Effect.gen(function* () {
394
const runtime = yield* AcpSessionRuntime.make({
395
...mockRuntimeOptions,
@@ -384,15 +397,31 @@ describe("AcpSessionRuntime", () => {
397
command: process.execPath,
398
args: [
399
"-e",
387
- "process.stderr.write(\"Invalid project config at /tmp/project/.cursor/cli.json: schema validation failed. Unrecognized key(s): 'approvalMode', 'sandbox'\\n\"); process.exit(1);",
400
+ `process.stderr.write("Invalid project config: Unrecognized key in cli.json\\nAuthorization: Bearer secret-token-value\\n", () => { ${testCase.terminate}; });`,
401
],
402
},
403
});
404
const error = yield* runtime.start().pipe(Effect.flip);
392
- expect(error._tag).toBe("AcpProcessExitedError");
393
- expect(error.message).toContain("cli.json");
394
- expect(error.message).toContain("Unrecognized key");
395
- expect(error.message).not.toContain("ACP process exited with code 1\nACP process exited");
405
+ assert.instanceOf(error, EffectAcpErrors.AcpProcessExitedError);
406
+ expect(error.code).toBe(testCase.code);
407
+ expect(error.signal).toBe(testCase.signal);
408
+ expect(error).toMatchObject({
409
+ pid: expect.any(Number),
410
+ stderr:
411
+ "Invalid project config: Unrecognized key in cli.json\nAuthorization: Bearer [redacted]",
412
+ });
413
+ expect(error.message).toBe(
414
+ `${testCase.signal ? "ACP process exited after signal SIGTERM" : "ACP process exited with code 1"}\nInvalid project config: Unrecognized key in cli.json\nAuthorization: Bearer [redacted]`,
415
+ );
416
+ if (testCase.signal) {
417
+ expect(error.cause).toMatchObject({
418
+ reason: {
419
+ module: "ChildProcess",
420
+ method: "exitCode",
421
+ cause: new Error("Process interrupted due to receipt of signal: 'SIGTERM'"),
422
+ },
423
+ });
424
+ }
425
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
426
);
427
packages/effect-acp/src/_internal/stdio.ts
+18
-6
@@ -53,11 +53,23 @@ export const makeTerminationError = (
53
handle: ChildProcessTerminationHandle,
54
): Effect.Effect<AcpError.AcpError> =>
55
Effect.match(handle.exitCode, {
56
- onFailure: (cause) =>
57
- new AcpError.AcpTransportError({
58
- operation: "read-process-exit-status",
59
- pid: handle.pid,
60
- cause,
61
- }),
56
+ onFailure: (cause) => {
57
+ // The Node spawner reports signal exits as a platform error rather than an exit code.
58
+ const signal =
59
+ cause.reason.module === "ChildProcess" &&
60
+ cause.reason.method === "exitCode" &&
61
+ cause.reason.cause instanceof Error
62
+ ? /^Process interrupted due to receipt of signal: '(SIG[A-Z0-9]+)'$/.exec(
63
+ cause.reason.cause.message,
64
+ )?.[1]
65
+ : undefined;
66
+ return signal === undefined
67
+ ? new AcpError.AcpTransportError({
68
+ operation: "read-process-exit-status",
69
+ pid: handle.pid,
70
+ cause,
71
+ })
72
+ : new AcpError.AcpProcessExitedError({ signal, pid: handle.pid, cause });
73
+ },
74
onSuccess: (code) => new AcpError.AcpProcessExitedError({ code, pid: handle.pid }),
75
});
packages/effect-acp/src/errors.ts
+6
-1
@@ -159,6 +159,7 @@ export class AcpProcessExitedError extends Schema.TaggedError<AcpProcessExitedEr
159
"AcpProcessExitedError",
160
{
161
code: Schema.optional(Schema.Number),
162
+ signal: Schema.optionalKey(Schema.String),
163
pid: Schema.optionalKey(Schema.Int),
164
stderr: Schema.optionalKey(Schema.String),
165
cause: Schema.optional(Schema.Defect()),
@@ -166,7 +167,11 @@ export class AcpProcessExitedError extends Schema.TaggedError<AcpProcessExitedEr
167
) {
168
override get message() {
169
const base =
169
- this.code === undefined ? "ACP process exited" : `ACP process exited with code ${this.code}`;
170
+ this.signal !== undefined
171
+ ? `ACP process exited after signal ${this.signal}`
172
+ : this.code === undefined
173
+ ? "ACP process exited"
174
+ : `ACP process exited with code ${this.code}`;
175
const excerpt = this.stderr?.trim();
176
return excerpt && excerpt.length > 0 ? `${base}\n${excerpt}` : base;
177
}
packages/provider-acp/src/server/AcpSessionRuntime.ts
+1
@@ -1331,6 +1331,7 @@ export const make = Effect.fn("AcpSessionRuntime.make")(function* (
1331
? error
1332
: new EffectAcpErrors.AcpProcessExitedError({
1333
...(error.code !== undefined ? { code: error.code } : {}),
1334
+ ...(error.signal !== undefined ? { signal: error.signal } : {}),
1335
...(error.pid !== undefined ? { pid: error.pid } : {}),
1336
stderr,
1337
...(error.cause !== undefined ? { cause: error.cause } : {}),
packages/provider-acp/src/server/stderr.test.ts
+3
@@ -17,6 +17,7 @@ describe("AcpStderr", () => {
17
[
18
"Invalid project config at /Users/ada/.cursor/cli.json",
19
"Authorization: Bearer secret-token-value",
20
+ "Sign in: https://accounts.google.com/o/oauth2/v2/auth?state=oauth-state-value",
21
"Visit http://localhost:5733/pair#token=ABCDEF for pairing",
22
"key=sk-abcdefghijklmnopqrstuv",
23
].join("\n"),
@@ -30,6 +31,8 @@ describe("AcpStderr", () => {
31
expect(excerpt).toContain("[redacted]");
32
expect(excerpt).not.toContain("secret-token-value");
33
expect(excerpt).not.toContain("ABCDEF");
34
+ expect(excerpt).toContain("[sign-in-url]");
35
+ expect(excerpt).not.toContain("oauth-state-value");
36
expect(excerpt).not.toContain("sk-abcdefghijklmnopqrstuv");
37
});
38
packages/provider-acp/src/server/stderr.ts
+2
@@ -1,6 +1,7 @@
1
export const ACP_STDERR_TAIL_MAX_CHARS = 4_096;
2
3
const PAIRING_URL_PATTERN = /https?:\/\/[^\s]*\/pair#[^\s]*/gi;
4
+const SIGN_IN_URL_PATTERN = /https?:\/\/accounts\.google\.com[^\s]*/gi;
5
const BEARER_TOKEN_PATTERN = /\bBearer\s+[A-Za-z0-9._\-+=/]+/gi;
6
const BASIC_AUTH_PATTERN = /\bAuthorization:\s*Basic\s+\S+/gi;
7
const API_KEY_HEADER_PATTERN = /\bx-api-key:\s*\S+/gi;
@@ -26,6 +27,7 @@ export function sanitizeAcpStderrExcerpt(
27
}
28
result = result
29
.replace(PAIRING_URL_PATTERN, "[pairing-url]")
30
+ .replace(SIGN_IN_URL_PATTERN, "[sign-in-url]")
31
.replace(BEARER_TOKEN_PATTERN, "Bearer [redacted]")
32
.replace(BASIC_AUTH_PATTERN, "Authorization: Basic [redacted]")
33
.replace(API_KEY_HEADER_PATTERN, "x-api-key: [redacted]")