Switch exec to fire-and-forget spawn, drop awaits
spawnSync was blocking the event loop until the subprocess exited, so opening a browser would freeze the server until it closed. Replace with spawn + unref (detached, stdio ignored) and remove the now-pointless awaits and async keywords from action handlers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { spawnSync } from "child_process";
|
||||
import { spawn } from "child_process";
|
||||
import path from "path";
|
||||
|
||||
const CONTAINER_PATH = "/home/devilholk/Projekt/claude-docker/";
|
||||
@@ -24,14 +24,7 @@ export function resolve_path(user_path) {
|
||||
throw new Error(`Path is outside all known volumes: ${user_path}`);
|
||||
}
|
||||
|
||||
// Execute a binary with an argument list — no shell interpolation.
|
||||
// Launch a binary with an argument list — no shell interpolation, fire and forget.
|
||||
export function exec(bin, args = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const result = spawnSync(bin, args, { stdio: "inherit" });
|
||||
if (result.error) {
|
||||
reject(result.error);
|
||||
} else {
|
||||
resolve(result.status);
|
||||
}
|
||||
});
|
||||
spawn(bin, args, { stdio: 'ignore', detached: true }).unref();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user