diff --git a/app/api/sandbox/route.ts b/app/api/sandbox/route.ts index ad73c3bc..ceed0433 100644 --- a/app/api/sandbox/route.ts +++ b/app/api/sandbox/route.ts @@ -50,10 +50,12 @@ export async function POST(req: Request) { // Copy code to fs if (fragment.code && Array.isArray(fragment.code)) { - fragment.code.forEach(async (file) => { - await sbx.files.write(file.file_path, file.file_content) - console.log(`Copied file to ${file.file_path} in ${sbx.sandboxId}`) - }) + await Promise.all( + fragment.code.map(async (file) => { + await sbx.files.write(file.file_path, file.file_content) + console.log(`Copied file to ${file.file_path} in ${sbx.sandboxId}`) + }), + ) } else { await sbx.files.write(fragment.file_path, fragment.code) console.log(`Copied file to ${fragment.file_path} in ${sbx.sandboxId}`)