Skip to content

Commit 06b5fc2

Browse files
committed
Fix inherited env vars overriding bootstrap config and Windows fd resolution
Bug 1: Strip T3CODE_MODE, T3CODE_PORT, T3CODE_HOME, T3CODE_NO_BROWSER, and T3CODE_AUTH_TOKEN from the child process environment in the desktop launcher. These values are now delivered exclusively via the bootstrap pipe; inheriting them from the parent shell allowed stray env vars to silently override the dynamically generated values (e.g. authToken, port), breaking WebSocket auth. Bug 2: On Windows there is no /dev/fd/ or /proc/self/fd/ virtual filesystem. Return undefined from resolveFdPath on win32 and fall back to using the inherited fd number directly, which Node's fs APIs accept natively.
1 parent 20c0564 commit 06b5fc2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

apps/desktop/src/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,13 @@ function startBackend(): void {
949949
env: {
950950
...process.env,
951951
ELECTRON_RUN_AS_NODE: "1",
952+
// Clear env vars that the bootstrap pipe now delivers, so stray
953+
// values inherited from the user's shell cannot override them.
954+
T3CODE_MODE: undefined,
955+
T3CODE_PORT: undefined,
956+
T3CODE_HOME: undefined,
957+
T3CODE_NO_BROWSER: undefined,
958+
T3CODE_AUTH_TOKEN: undefined,
952959
},
953960
stdio: captureBackendLogs
954961
? ["ignore", "pipe", "pipe", "pipe"]

apps/server/src/bootstrap.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ export const readBootstrapEnvelope = Effect.fn("readBootstrapEnvelope")(function
3535
if (!fdReady) return Option.none();
3636

3737
const streamFd = yield* Effect.try({
38-
try: () => NFS.openSync(resolveFdPath(fd), "r"),
38+
try: () => {
39+
const fdPath = resolveFdPath(fd);
40+
if (fdPath === undefined) return fd;
41+
return NFS.openSync(fdPath, "r");
42+
},
3943
catch: (error) =>
4044
new BootstrapError({
4145
message: "Failed to duplicate bootstrap fd.",
@@ -113,9 +117,12 @@ function isUnavailableBootstrapFdError(error: unknown): boolean {
113117
);
114118
}
115119

116-
function resolveFdPath(fd: number): string {
120+
function resolveFdPath(fd: number): string | undefined {
117121
if (process.platform === "linux") {
118122
return `/proc/self/fd/${fd}`;
119123
}
124+
if (process.platform === "win32") {
125+
return undefined;
126+
}
120127
return `/dev/fd/${fd}`;
121128
}

0 commit comments

Comments
 (0)