Skip to content

Commit e0c821c

Browse files
committed
Special-case this fix to Electron apps
1 parent 17a32b1 commit e0c821c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: src/client/stdio.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,18 @@ export class StdioClientTransport implements Transport {
112112
env: this._serverParams.env ?? getDefaultEnvironment(),
113113
stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
114114
shell: false,
115-
detached: process.platform === "win32",
116115
signal: this._abortController.signal,
117-
},
116+
117+
// NB: The behavior of detached varies based on platform, and also
118+
// is different based on whether the process is a Win32 Subsystem
119+
// process or a Console Subsystem process. Strangely, the behavior
120+
// of detached is almost 1:1 the opposite in Electron+Windows vs
121+
// what is documented on the node.js website, and also is different
122+
// based on whether you launch Electron in a development environment
123+
// (i.e. via `electron-forge start`) vs a production environment
124+
// (i.e. YourApp.exe).
125+
detached: process.platform === "win32" && isElectron(),
126+
}
118127
);
119128

120129
this._process.on("error", (error) => {
@@ -188,3 +197,7 @@ export class StdioClientTransport implements Transport {
188197
});
189198
}
190199
}
200+
201+
function isElectron() {
202+
return "type" in process;
203+
}

0 commit comments

Comments
 (0)