-
Notifications
You must be signed in to change notification settings - Fork 46
Closed
Description
Problem
When using startProcess() for tasks that exit on their own, there's no clean way to wait for completion. Users must either:
- Use
waitForLog()with a known output pattern - Manually wrap
onExitcallback in a Promise
// Current workaround
let resolveExit: (code: number | null) => void;
const exitPromise = new Promise<number | null>((r) => resolveExit = r);
const process = await sandbox.startProcess('npm run build', { onExit: resolveExit });
await exitPromise;Proposal
Add waitForExit(timeout?) to Process objects, complementing existing waitForLog() and waitForPort():
const process = await sandbox.startProcess('npm run build');
const exitCode = await process.waitForExit(60000);Use Cases
- Run multiple processes concurrently, wait for specific ones to finish
- Start a process, do other work, then wait for completion
- Start a process that might run indefinitely, but check if it crashed early
Metadata
Metadata
Assignees
Labels
No labels