mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 05:40:22 +08:00
fix: 工作目录字面量恢复 + 桌面退出留痕,版本 1.1.89(#202/#204/#207)
This commit is contained in:
1 parent
d1eff01eb6
commit
c63ba4a720
6 files changed
+185
-50
No files matched your search
+66
-22
@@ -3615,7 +3615,7 @@ const NEW_TOOL_PATCHES = [
|
||||
},
|
||||
// rc.5 的 web-app-lib 已经不含这段提示词;留一个代码注释标记,避免整条补丁永远显示 drifted。
|
||||
{
|
||||
pattern: "export { Config, apply, inject, internals, name };",
|
||||
pattern: /export \{ Config, apply, inject, internals, name \};(?!\s*(?:\/\* \[dsh-purge\] web surface prohibition cleared|\/\/ \[dsh-purge\] web surface identity neutralized))/,
|
||||
replace: "export { Config, apply, inject, internals, name }; // [dsh-purge] web surface identity neutralized",
|
||||
},
|
||||
],
|
||||
@@ -4711,7 +4711,7 @@ const NEW_TOOL_PATCHES = [
|
||||
// rc.5 的 web-app-lib 已经不含这段文案;留一个代码注释标记,
|
||||
// 避免该文件既无 pattern 又无 marker,把整条补丁拖成 drifted。
|
||||
{
|
||||
pattern: /export \{ Config, apply, inject, internals, name \};/,
|
||||
pattern: /export \{ Config, apply, inject, internals, name \};(?!\s*\/\* \[dsh-purge\] web surface prohibition cleared)/,
|
||||
replace:
|
||||
"export { Config, apply, inject, internals, name }; /* [dsh-purge] web surface prohibition cleared */",
|
||||
insertProbe: "[dsh-purge] web surface prohibition cleared",
|
||||
@@ -4880,36 +4880,80 @@ const NEW_TOOL_PATCHES = [
|
||||
markers: ["[dsh-purge] close no-fail v2"],
|
||||
},
|
||||
{
|
||||
// #194:host 被信号杀时 #83 直接静默 resolve,UI 端永远不知道 host 已经没了,
|
||||
// 窗口自然不出现。这里保持“不弹对话框”,但把退出事实写进持久化日志,
|
||||
// 下次排查至少能看到 signal / code / stderr 尾巴。
|
||||
id: 91,
|
||||
name: "DESKTOP_HOST_SIGNAL_EXIT_LOG",
|
||||
// #207:dir 模式静默退出时,host 的 close 回调是唯一知道真实退出码的地方。
|
||||
// #83 在 signal 分支直接 resolve 不记录,这里把每条退出路径都记下来。
|
||||
id: 92,
|
||||
name: "DESKTOP_HOST_EXIT_TRACE",
|
||||
layer: "代码",
|
||||
layer_en: "Code",
|
||||
desc: "host 被信号杀时写持久化退出日志(仍不弹对话框) / persist a trace when the host dies by signal",
|
||||
desc: "host 每次退出都写 code/signal/stderr 到持久化日志 / persist every host exit",
|
||||
file: ["desktop-shell"],
|
||||
surfaces: ["desktop"],
|
||||
optional: true,
|
||||
skipIfMarked: true,
|
||||
replacements: [
|
||||
{
|
||||
pattern: "if (code === null || signal) { resolve(); return; }",
|
||||
pattern:
|
||||
"\t\t\tchild.once(\"close\", (code, signal) => {\n" +
|
||||
"\t\t\t\tconst suffix = this.stderr.trim() === \"\" ? \"\" : `: ${this.stderr.trim()}`;",
|
||||
replace:
|
||||
"if (code === null || signal) {\n" +
|
||||
"\t\t\t\t\t/* [dsh-purge] host signal exit logged */\n" +
|
||||
"\t\t\t\t\ttry {\n" +
|
||||
"\t\t\t\t\t\tconst _req = typeof require === \"function\" ? require : null;\n" +
|
||||
"\t\t\t\t\t\tconst _fs = typeof process.getBuiltinModule === \"function\" ? process.getBuiltinModule(\"node:fs\") : (_req ? _req(\"node:fs\") : null);\n" +
|
||||
"\t\t\t\t\t\tconst _os = typeof process.getBuiltinModule === \"function\" ? process.getBuiltinModule(\"node:os\") : (_req ? _req(\"node:os\") : null);\n" +
|
||||
"\t\t\t\t\t\tconst _log = _fs && _os ? _os.tmpdir() + \"/dsh-purge-desktop.log\" : \"\";\n" +
|
||||
"\t\t\t\t\t\tif (_log) _fs.appendFileSync(_log, new Date().toISOString() + \" [desktop.hostExit] signal=\" + String(signal) + \" code=\" + String(code) + suffix + \"\\n\", \"utf8\");\n" +
|
||||
"\t\t\t\t\t} catch {}\n" +
|
||||
"\t\t\t\t\tresolve(); return;\n" +
|
||||
"\t\t\t\t}",
|
||||
"\t\t\tchild.once(\"close\", (code, signal) => {\n" +
|
||||
"\t\t\t\tconst suffix = this.stderr.trim() === \"\" ? \"\" : `: ${this.stderr.trim()}`;\n" +
|
||||
"\t\t\t\t// [dsh-purge] host exit logged: 所有退出路径都留痕,dir 模式静默退出才查得动\n" +
|
||||
"\t\t\t\ttry {\n" +
|
||||
"\t\t\t\t\tconst _fs = typeof process.getBuiltinModule === \"function\" ? process.getBuiltinModule(\"node:fs\") : null;\n" +
|
||||
"\t\t\t\t\tconst _os = typeof process.getBuiltinModule === \"function\" ? process.getBuiltinModule(\"node:os\") : null;\n" +
|
||||
"\t\t\t\t\tif (_fs && _os) _fs.appendFileSync(_os.tmpdir() + \"/dsh-purge-desktop.log\", new Date().toISOString() + \" [desktop.hostExit] code=\" + String(code) + \" signal=\" + String(signal) + suffix + \"\\n\", \"utf8\");\n" +
|
||||
"\t\t\t\t} catch {}",
|
||||
},
|
||||
],
|
||||
markers: ["[dsh-purge] host signal exit logged"],
|
||||
markers: ["[dsh-purge] host exit logged"],
|
||||
},
|
||||
{
|
||||
// #207:主进程自己静默退出时完全没人记录原因。挂一层生命周期日志,
|
||||
// 记录 before-quit / will-quit / quit(exitCode) / 渲染进程崩溃 / 信号 / 未捕获异常。
|
||||
id: 93,
|
||||
name: "DESKTOP_MAIN_EXIT_TRACE",
|
||||
layer: "代码",
|
||||
layer_en: "Code",
|
||||
desc: "主进程退出原因写持久化日志(quit/信号/崩溃/未捕获异常) / trace why the desktop main process exits",
|
||||
file: ["desktop-shell"],
|
||||
surfaces: ["desktop"],
|
||||
optional: true,
|
||||
replacements: [
|
||||
{
|
||||
pattern: "if (claimDesktopSingleInstance(app, () => {\n\tfocusPrimaryWindow();\n}))",
|
||||
replace:
|
||||
"/* [dsh-purge] desktop exit trace */\n" +
|
||||
"try {\n" +
|
||||
"\tconst _df = typeof process.getBuiltinModule === \"function\" ? process.getBuiltinModule(\"node:fs\") : null;\n" +
|
||||
"\tconst _do = typeof process.getBuiltinModule === \"function\" ? process.getBuiltinModule(\"node:os\") : null;\n" +
|
||||
"\tconst _dlog = _df && _do ? _do.tmpdir() + \"/dsh-purge-desktop.log\" : \"\";\n" +
|
||||
"\tif (_dlog) {\n" +
|
||||
"\t\tconst _dt = (tag, extra) => {\n" +
|
||||
"\t\t\ttry { _df.appendFileSync(_dlog, new Date().toISOString() + \" [desktop.exit] \" + tag + (extra === void 0 ? \"\" : \" \" + String(extra)) + \"\\n\", \"utf8\"); } catch {}\n" +
|
||||
"\t\t};\n" +
|
||||
"\t\t_dt(\"boot pid=\" + process.pid + \" appPath=\" + app.getAppPath() + \" electron=\" + process.versions.electron);\n" +
|
||||
"\t\tprocess.on(\"exit\", (code) => _dt(\"process.exit code=\" + String(code)));\n" +
|
||||
"\t\t// 只用 monitor:挂 uncaughtException 本体就会吞掉崩溃、把退出改成继续跑。\n" +
|
||||
"\t\tprocess.on(\"uncaughtExceptionMonitor\", (error) => _dt(\"uncaughtException\", error && error.stack || error));\n" +
|
||||
"\t\tfor (const sig of [\"SIGTERM\", \"SIGINT\", \"SIGBREAK\"]) process.on(sig, () => _dt(\"signal \" + sig));\n" +
|
||||
"\t\tapp.on(\"before-quit\", () => _dt(\"before-quit\"));\n" +
|
||||
"\t\tapp.on(\"will-quit\", () => _dt(\"will-quit\"));\n" +
|
||||
"\t\tapp.on(\"quit\", (_event, code) => _dt(\"quit code=\" + String(code)));\n" +
|
||||
"\t\tapp.on(\"window-all-closed\", () => _dt(\"window-all-closed\"));\n" +
|
||||
"\t\tapp.on(\"render-process-gone\", (_event, _contents, details) => {\n" +
|
||||
"\t\t\tlet _tail = \"\";\n" +
|
||||
"\t\t\ttry { _tail = \" console=\" + JSON.stringify(rendererConsole.snapshot()); } catch {}\n" +
|
||||
"\t\t\t_dt(\"render-process-gone\", JSON.stringify(details) + _tail);\n" +
|
||||
"\t\t});\n" +
|
||||
"\t\tapp.on(\"child-process-gone\", (_event, details) => _dt(\"child-process-gone\", JSON.stringify(details)));\n" +
|
||||
"\t\tsetInterval(() => _dt(\"alive\"), 60000).unref();\n" +
|
||||
"\t}\n" +
|
||||
"} catch {}\n" +
|
||||
"if (claimDesktopSingleInstance(app, () => {\n\tfocusPrimaryWindow();\n}))",
|
||||
},
|
||||
],
|
||||
markers: ["[dsh-purge] desktop exit trace"],
|
||||
},
|
||||
{
|
||||
id: 67,
|
||||
|
||||
Reference in new issue
Block a user