Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(desktop): 原生崩溃退出码给出可读诊断 (#976)

iuuuuuuuuc44f9f570cb1
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index 60e69600..a36d70b9 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -115,6 +115,7 @@
"errors.startup_absolute": "Harness exceeded the maximum allowed time for {{phase}}. Last readiness status: {{reason}}",
"errors.startup_exited": "Harness exited during {{phase}}. Last readiness status: {{reason}}",
"errors.process_exited_with_code": "Harness stopped unexpectedly (exit code {{code}}). Restart to continue.",
+ "errors.process_exited_native_crash": "The Harness process was killed by the system (exit code {{code}}, a native Windows crash). This is not a heap exhaustion: no JavaScript exception will appear in the log. A graphics driver or a native module is the usual cause. Restart to continue.",
"errors.process_exited_without_code": "Harness stopped unexpectedly. Restart to continue.",
"errors.no_readiness_reason": "No readiness reason was reported.",
"errors.client_boot_stalled": "The client remained on Loading plugins after all bounded reload attempts.",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index c4756ae5..72974afc 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -115,6 +115,7 @@
"errors.startup_absolute": "Harness 在{{phase}}阶段超过最长允许时间。最后的就绪状态:{{reason}}",
"errors.startup_exited": "Harness 在{{phase}}阶段退出。最后的就绪状态:{{reason}}",
"errors.process_exited_with_code": "Harness 意外停止(退出码 {{code}})。请重新启动以继续。",
+ "errors.process_exited_native_crash": "Harness 进程被系统强制终止(退出码 {{code}},Windows 原生崩溃)。这不是内存耗尽,日志里不会有 JS 异常;常见原因是显卡驱动或某个原生模块。请重新启动以继续。",
"errors.process_exited_without_code": "Harness 意外停止。请重新启动以继续。",
"errors.no_readiness_reason": "后端未报告就绪原因。",
"errors.client_boot_stalled": "客户端在全部有界刷新尝试后仍停留在 Loading plugins。",
diff --git a/src/store/modules/harness/runtime.ts b/src/store/modules/harness/runtime.ts
index fa3cd809..d9d17727 100644
--- a/src/store/modules/harness/runtime.ts
+++ b/src/store/modules/harness/runtime.ts
@@ -35,5 +35,21 @@ export function shouldAcceptRuntimeExit({
export function runtimeExitMessageKey(exitCode: number | null | undefined): string {
if (exitCode == null)
return 'errors.process_exited_without_code'
+ if (isNativeCrashCode(exitCode))
+ return 'errors.process_exited_native_crash'
return 'errors.process_exited_with_code'
}
+
+/** Windows NTSTATUS 形态的原生退出码:0xC0000005 访问违例 / 0xC0000409 栈缓冲溢出等。 */
+const NATIVE_CRASH_CODES = new Set([
+ 0xC0000005,
+ 0xC0000409,
+ 0xC0000374,
+ 0xC000001D,
+ 0xC00000FD,
+])
+
+/** 退出码是否为 Windows 原生崩溃(不是 JS 层异常,也不是 V8 堆耗尽)。 */
+export function isNativeCrashCode(exitCode: number | null | undefined): boolean {
+ return exitCode != null && NATIVE_CRASH_CODES.has(exitCode >>> 0)
+}
diff --git a/src/store/modules/harness/utils.ts b/src/store/modules/harness/utils.ts
index 5382001c..ebeb548b 100644
--- a/src/store/modules/harness/utils.ts
+++ b/src/store/modules/harness/utils.ts
@@ -107,7 +107,8 @@ export async function checkHealthViaProxy(): Promise<ReadinessProbeResult> {
if (message.includes('HARNESS_NOT_OWNED')) {
// dsh 进程已退出(典型如插件冲突导致启动即崩溃),继续等只会白白耗完
// 当前阶段 deadline,让调用方立刻结束并展示日志里的真实错误。
- console.warn('[Harness] dsh process exited during startup, failing fast')
+ // 运行期崩溃走的是另一条路径(handleProcessExit),这里能到就说明还在启动轮询里。
+ console.warn('[Harness] dsh process exited before readiness, failing fast')
return {
healthy: false,
notOwned: true,
diff --git a/test/runtime-exit.test.ts b/test/runtime-exit.test.ts
index 18ee96b4..56e84ade 100644
--- a/test/runtime-exit.test.ts
+++ b/test/runtime-exit.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
-import { runtimeExitMessageKey, shouldAcceptRuntimeExit } from '../src/store/modules/harness/runtime'
+import { isNativeCrashCode, runtimeExitMessageKey, shouldAcceptRuntimeExit } from '../src/store/modules/harness/runtime'
describe('runtime exit acceptance', () => {
const current = {
@@ -46,4 +46,19 @@ describe('runtime exit acceptance', () => {
expect(runtimeExitMessageKey(null)).toBe('errors.process_exited_without_code')
expect(runtimeExitMessageKey(undefined)).toBe('errors.process_exited_without_code')
})
+
+ it('uses the native crash wording only for Windows NTSTATUS exit codes', () => {
+ // 0xC0000005 访问违例:实测用户机器上 Harness 跑满 12 小时后被原生层打死,
+ // 日志里没有任何 JS 异常,旧文案只报裸数字,容易被当成堆耗尽。
+ expect(isNativeCrashCode(0xC0000005)).toBe(true)
+ expect(runtimeExitMessageKey(0xC0000005)).toBe('errors.process_exited_native_crash')
+ expect(runtimeExitMessageKey(3221225477)).toBe('errors.process_exited_native_crash')
+ expect(isNativeCrashCode(0xC0000409)).toBe(true)
+ expect(isNativeCrashCode(0xC0000374)).toBe(true)
+ expect(isNativeCrashCode(0xC000001D)).toBe(true)
+ expect(isNativeCrashCode(0xC00000FD)).toBe(true)
+ expect(isNativeCrashCode(134)).toBe(false)
+ expect(isNativeCrashCode(1)).toBe(false)
+ expect(isNativeCrashCode(null)).toBe(false)
+ })
})