1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

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 2022-11-04 13:20:19 +02:00 committed by GitHub
parent c527014011
commit d63bf277b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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));