diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index ebf8df4..da51a46 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -432,11 +432,12 @@ io.on("connection", async (socket) => { socket.on("disconnect", async () => { if (data.isOwner) { - Object.entries(terminals).forEach((t) => { - const terminal = t[1]; - terminal.kill(); - delete terminals[t[0]]; - }); + await Promise.all( + Object.entries(terminals).map(async ([key, terminal]) => { + await terminal.kill(); + delete terminals[key]; + }) + ); await lockManager.acquireLock(data.sandboxId, async () => { try {