Skip to content

Commit

Permalink
Special-case this fix to Electron apps
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Nov 20, 2024
1 parent 17a32b1 commit e0c821c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/client/stdio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -188,3 +197,7 @@ export class StdioClientTransport implements Transport {
});
}
}

function isElectron() {
return "type" in process;
}

0 comments on commit e0c821c

Please sign in to comment.