From a3cdcc779630fa10e916cde670c0d405f9a52a58 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 3 Oct 2026 01:54:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(sandbox):=20=E6=96=87=E6=A1=88=E6=A0=87?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/server/src/sandbox/client.ts | 6 +++--- apps/server/src/sandbox/worker.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/sandbox/client.ts b/apps/server/src/sandbox/client.ts index 81053d1c..4c2a4e36 100644 --- a/apps/server/src/sandbox/client.ts +++ b/apps/server/src/sandbox/client.ts @@ -83,7 +83,7 @@ export async function runSandbox( }).spawn(); } catch (e) { inProcessReason = (e as Error).message; - console.warn(`[sandbox] 起不来子进程,退回进程内执行:${inProcessReason}`); + console.warn(`[sandbox] 起不来子进程,退回进程内执行:${inProcessReason}`); return runInProcess(job, input, timeoutMs) as Promise>; } stats.spawned += 1; @@ -128,7 +128,7 @@ export async function runSandbox( msg = JSON.parse(line); } catch { stats.crashes += 1; - throw new SandboxError("crash", `沙箱任务 ${job} 异常退出(code ${status.code}):${stderr.trim().slice(-300)}`); + throw new SandboxError("crash", `沙箱任务 ${job} 异常退出(code ${status.code}):${stderr.trim().slice(-300)}`); } if (!msg.ok) throw new SandboxError("job", msg.error ?? "沙箱任务失败"); return msg.result as SandboxOutput; @@ -150,7 +150,7 @@ async function runInProcess( return await Promise.race([ Promise.resolve().then(() => fn(input)), new Promise((_, reject) => { - timer = setTimeout(() => reject(new SandboxError("timeout", `沙箱任务 ${job} 超时(进程内)`)), timeoutMs); + timer = setTimeout(() => reject(new SandboxError("timeout", `沙箱任务 ${job} 超时(进程内)`)), timeoutMs); }), ]); } catch (e) { diff --git a/apps/server/src/sandbox/worker.ts b/apps/server/src/sandbox/worker.ts index 8f234f72..ed5e9ae8 100644 --- a/apps/server/src/sandbox/worker.ts +++ b/apps/server/src/sandbox/worker.ts @@ -21,7 +21,7 @@ export async function sandboxWorkerMain(): Promise { try { const req = JSON.parse(await new Response(Deno.stdin.readable).text()) as { job: string; input: unknown }; const fn = (SANDBOX_JOBS as Record unknown>)[req.job]; - if (!fn) throw new Error(`没有这个沙箱任务:${req.job}`); + if (!fn) throw new Error(`没有这个沙箱任务:${req.job}`); out = { ok: true, result: await fn(req.input) }; } catch (e) { out = { ok: false, error: `${(e as Error).name}: ${(e as Error).message}`.slice(0, 2000) };