Timeouts
The SDK has a number of timeouts that can be configured to control how long the SDK will wait for a response from the E2B servers. The default is 60 seconds.
Timeout creating sandbox
import { Sandbox } from 'e2b'
// Timeout 3s for the sandbox to open
const sandbox = await Sandbox.create({
template: 'base',
timeout: 3000,
})
await sandbox.close()
Timeout process
import { Sandbox } from 'e2b'
const sandbox = await Sandbox.create({ template: 'base' })
// Timeout 3s for the process to start
const npmInit = await sandbox.process.start({
cmd: 'npm init -y',
timeout: 3000,
})
await npmInit.wait()
await sandbox.close()
Timeout filesystem operations
import { Sandbox } from 'e2b'
const sandbox = await Sandbox.create({ template: 'base' })
// Timeout 3s for the write operation
await sandbox.filesystem.write('hello.txt', 'Hello World!', {timeout: 3000})
// Timeout 3s for the list operation
const files = await sandbox.filesystem.list('.', {timeout: 3000})
console.log(files)
// Timeout 3s for the read operation
const content = await sandbox.filesystem.read('hello.txt', {timeout: 3000})
console.log(content)
await sandbox.close()