Fully detach autoupgrade process (#14595)

This commit is contained in:
Tommaso Sciortino
2025-12-05 14:12:54 -08:00
committed by GitHub
parent 04cbae5b5f
commit bdd15e8911
2 changed files with 14 additions and 20 deletions

View File

@@ -68,11 +68,13 @@ export function handleAutoUpdate(
'@latest',
isNightly ? '@nightly' : `@${info.update.latest}`,
);
const updateProcess = spawnFn(updateCommand, { stdio: 'pipe', shell: true });
let errorOutput = '';
updateProcess.stderr.on('data', (data) => {
errorOutput += data.toString();
const updateProcess = spawnFn(updateCommand, {
stdio: 'ignore',
shell: true,
detached: true,
});
// Un-reference the child process to allow the parent to exit independently.
updateProcess.unref();
updateProcess.on('close', (code) => {
if (code === 0) {
@@ -82,7 +84,7 @@ export function handleAutoUpdate(
});
} else {
updateEventEmitter.emit('update-failed', {
message: `Automatic update failed. Please try updating manually. (command: ${updateCommand}, stderr: ${errorOutput.trim()})`,
message: `Automatic update failed. Please try updating manually. (command: ${updateCommand})`,
});
}
});