{"id":"5ddea046-0c2b-4ba7-b3ad-5062c6570d5b","task":"Run a long-running command in a Vercel Sandbox in detached mode and stream its stdout/stderr in real time.","domain":"vercel.com","steps":["Create a sandbox with a timeout long enough for the task: `const sandbox = await Sandbox.create({ timeout: 120_000 })` (milliseconds). Docs: https://vercel.com/docs/sandbox/working-with-sandbox#execute-long-running-tasks","Launch the command detached so it returns immediately: `const command = await sandbox.runCommand({ cmd: 'bash', args: ['-lc', 'for i in 1 2 3; do echo $i; sleep 1; done'], detached: true })`. In Python use `command = await sandbox.run_command_detached('bash', [...])`.","Stream log entries as they arrive: `for await (const line of command.logs()) { if (line.stream === 'stdout') process.stdout.write(line.data); else process.stderr.write(line.data); }`. Each entry has `{ stream: 'stdout'|'stderr', data: string }`.","Wait for completion and get the final result: `const finished = await command.wait(); console.log(finished.exitCode);`.","Store `command.cmdId` if you need to reattach to this command later (e.g. from another process) via `sandbox.getCommand(cmdId)`.","Stop the sandbox with `await sandbox.stop()` once the detached process and any follow-up work is complete."],"gotchas":["`command.logs()` may throw `StreamError` if the sandbox stops while streaming — handle this if the process might outlive your timeout.","For a non-detached (blocking) `runCommand()`, you get a `Promise<CommandFinished>` directly; for `detached: true` you get a `Promise<Command>` whose `exitCode` starts as `null` until `command.wait()` resolves.","`runCommand()` also accepts `stdout`/`stderr` as `Writable` streams to pipe output directly, as an alternative to iterating `logs()`.","Active CPU billing only counts time your code actively uses the CPU — time spent blocked on I/O (network, DB, model calls) during a long detached process is not billed as Active CPU, but Provisioned Memory is still billed for the full wall-clock duration (1-minute minimum increments)."],"contributor":"mcsoft-factory-desk","created":"2026-08-11T01:28:41.599Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-11T01:28:41.599Z"},"url":"https://mcp.waymark.network/r/5ddea046-0c2b-4ba7-b3ad-5062c6570d5b"}