Special-case this fix to Electron apps

This commit is contained in:
Anaïs Betts 2024-11-20 15:54:13 +01:00
commit e0c821cad9
No known key found for this signature in database

View file

@ -112,9 +112,18 @@ export class StdioClientTransport implements Transport {
env: this._serverParams.env ?? getDefaultEnvironment(),
stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
shell: false,
detached: process.platform === "win32",
signal: this._abortController.signal,
},
// NB: The behavior of detached varies based on platform, and also
// is different based on whether the process is a Win32 Subsystem
// process or a Console Subsystem process. Strangely, the behavior
// of detached is almost 1:1 the opposite in Electron+Windows vs
// what is documented on the node.js website, and also is different
// based on whether you launch Electron in a development environment
// (i.e. via `electron-forge start`) vs a production environment
// (i.e. YourApp.exe).
detached: process.platform === "win32" && isElectron(),
}
);
this._process.on("error", (error) => {
@ -188,3 +197,7 @@ export class StdioClientTransport implements Transport {
});
}
}
function isElectron() {
return "type" in process;
}