fix: 🐛 Fix windows hanging when client agent isn't running (#2459)

This commit is contained in:
Zhihe Li committed 2024-09-24 11:58:25 -04:00
1 parent 1266930647
commit 6cd2f0f7d8
1 file changed
+15 -2
@@ -90,9 +90,9 @@ module.exports = {
},
});
const { stdout, stderr } = childProcess;
const { stdout, stderr, error } = childProcess;
return { stdout: stdout?.toString(), stderr: stderr?.toString() };
return { stdout: stdout?.toString(), stderr: stderr?.toString(), error };
},
/**
@@ -111,6 +111,19 @@ module.exports = {
resolve({ childProcess, stderr: data.toString() });
});
childProcess.on('error', (err) => reject(err));
// In case the process has no stdio and didn't error out, resolve a
// promise once the child process closes so we're not waiting forever.
// Windows doesn't seem to return any error nor any output from stderr when
// a timeout occurs so this guarantees we return a response to the caller.
// Otherwise this should not get hit as we should be returning a response
// from one of the handlers above.
childProcess.on('close', () =>
resolve({
childProcess,
stderr: JSON.stringify({ error: 'Process was closed.' }),
}),
);
});
},
};