Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: guard MuScriptor installer child process close handler against unhandled rejections (#8908)

[._.]/ Adam Eivy39dd34d69f17
diff --git a/server/routes/midiRuntime.js b/server/routes/midiRuntime.js
index 62435906d3..2ffc18098a 100644
--- a/server/routes/midiRuntime.js
+++ b/server/routes/midiRuntime.js
@@ -144,24 +144,30 @@ router.post('/install', asyncHandler(async (req, res) => {
safeEnd();
});
child.on('close', async (code) => {
- stdoutReader.flush();
- stderrReader.flush();
- finished = true;
- installInFlight = null;
- // Drop the cached resolve/ready so this probe (and the next transcription)
- // sees the freshly-created venv, then verify the import rather than trusting
- // the exit code alone — the setup script import-verifies MuScriptor and
- // exits non-zero on failure, but a partial venv shouldn't be reported "ready".
- invalidateMuscriptorPython();
- const ready = await isMuscriptorRuntimeReady();
- if (code === 0 && ready) {
- emit({ type: 'complete', message: `MuScriptor ready: ${resolveMuscriptorPython()}` });
- } else if (code === 0) {
- emit({ type: 'error', message: `Installer exited 0 but MuScriptor can't be imported from ${MUSCRIPTOR_VENV_DEFAULT}. Re-run from a terminal to see what happened.` });
- } else {
- emit({ type: 'error', message: `Installer exited with code ${code}.` });
+ try {
+ stdoutReader.flush();
+ stderrReader.flush();
+ finished = true;
+ installInFlight = null;
+ // Drop the cached resolve/ready so this probe (and the next transcription)
+ // sees the freshly-created venv, then verify the import rather than trusting
+ // the exit code alone — the setup script import-verifies MuScriptor and
+ // exits non-zero on failure, but a partial venv shouldn't be reported "ready".
+ invalidateMuscriptorPython();
+ const ready = await isMuscriptorRuntimeReady();
+ if (code === 0 && ready) {
+ emit({ type: 'complete', message: `MuScriptor ready: ${resolveMuscriptorPython()}` });
+ } else if (code === 0) {
+ emit({ type: 'error', message: `Installer exited 0 but MuScriptor can't be imported from ${MUSCRIPTOR_VENV_DEFAULT}. Re-run from a terminal to see what happened.` });
+ } else {
+ emit({ type: 'error', message: `Installer exited with code ${code}.` });
+ }
+ safeEnd();
+ } catch (err) {
+ console.error(`❌ MuScriptor install completion check failed: ${err.message}`);
+ emit({ type: 'error', message: `Install completion check failed: ${err.message}` });
+ safeEnd();
}
- safeEnd();
});
}));