Fix compute unix shell environment timeout (#6516)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2022-11-04 07:20:19 -04:00
1 parent c527014011
commit d63bf277b2
1 file changed
+4 -5
@@ -9,10 +9,10 @@ import spawnInjectable from "../../child-process/spawn.injectable";
import randomUUIDInjectable from "../../crypto/random-uuid.injectable";
export interface UnixShellEnvOptions {
signal?: AbortSignal;
signal: AbortSignal;
}
export type ComputeUnixShellEnvironment = (shell: string, opts?: UnixShellEnvOptions) => Promise<EnvironmentVariables>;
export type ComputeUnixShellEnvironment = (shell: string, opts: UnixShellEnvOptions) => Promise<EnvironmentVariables>;
const computeUnixShellEnvironmentInjectable = getInjectable({
id: "compute-unix-shell-environment",
@@ -46,7 +46,7 @@ const computeUnixShellEnvironmentInjectable = getInjectable({
};
};
return async (shellPath, opts = {}) => {
return async (shellPath, opts) => {
const runAsNode = process.env["ELECTRON_RUN_AS_NODE"];
const noAttach = process.env["ELECTRON_NO_ATTACH_CONSOLE"];
const env = {
@@ -61,12 +61,11 @@ const computeUnixShellEnvironmentInjectable = getInjectable({
return new Promise((resolve, reject) => {
const shellProcess = spawn(shellPath, shellArgs, {
detached: true,
signal: opts.signal,
env,
});
const stdout: Buffer[] = [];
opts.signal?.addEventListener("abort", () => shellProcess.kill());
shellProcess.stdout.on("data", b => stdout.push(b));
shellProcess.on("error", (err) => reject(err));