Fix README example: move reset() inside exit callback (#54)

The previous example called reset() immediately after spawning the
child process, which would shut down proxy servers before the child
process completes. This caused the sandboxed command to fail.

Move reset() inside the 'exit' event callback to ensure cleanup
happens after the child process terminates.
This commit is contained in:
ryoppippi
2026-02-02 09:31:11 +00:00
committed by GitHub
parent 7a4d699bcd
commit ec0c24c41d

View File

@@ -203,13 +203,12 @@ const sandboxedCommand = await SandboxManager.wrapWithSandbox(
// Execute the sandboxed command
const child = spawn(sandboxedCommand, { shell: true, stdio: 'inherit' })
// Handle exit
child.on('exit', code => {
// Handle exit and cleanup after child process completes
child.on('exit', async code => {
console.log(`Command exited with code ${code}`)
// Cleanup when done (optional, happens automatically on process exit)
await SandboxManager.reset()
})
// Cleanup when done (optional, happens automatically on process exit)
await SandboxManager.reset()
```
#### Available exports