Describe the bug
When you try to call runCode() od CodeInterpreter sandbox it throws "bufferutil.mask is not a function" which appears to be related to this issue
https://github.com/websockets/bufferutil/issues/146
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { CodeInterpreter } from '@e2b/sdk'
import { kv } from '@vercel/kv'
const TTL = 10 * 60_000 // 10 minutes
export async function POST(req: NextRequest, res: NextResponse) {
let sbx: CodeInterpreter
const now = Date.now()
if (sandboxID && lastUsed && now - lastUsed < TTL) {
console.log('Reconnecting to sandbox:', sandboxID)
sbx = await CodeInterpreter.reconnect(sandboxID)
} else {
console.log('Creating new sandbox...')
sbx = await CodeInterpreter.create({
logger: console,
})
console.log('Created sandbox:', sbx.id)
await kv.hset('sandbox', { id: sbx.id })
}
const { stdout, stderr } = await sbx.runPython('print("hello")')
console.log(stdout)
console.error(stderr)
// Keep sandbox alive for 10 minutes
await kv.hset('sandbox', { lastUsed: now })
await sbx.keepAlive(TTL)
await sbx.close()
return NextResponse.json({},
{
status: 200,
},
)
}
Describe the bug When you try to call
runCode()
odCodeInterpreter
sandbox it throws "bufferutil.mask
is not a function" which appears to be related to this issue https://github.com/websockets/bufferutil/issues/146E2B-445