Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(workspaces): win32 上 desktop unit 回退 forks 池,threads 会段错误

DavidShen576c2a04de16
diff --git a/scripts/__tests__/test-workspaces.test.mjs b/scripts/__tests__/test-workspaces.test.mjs
index 36592ca758..96d4207711 100644
--- a/scripts/__tests__/test-workspaces.test.mjs
+++ b/scripts/__tests__/test-workspaces.test.mjs
@@ -169,7 +169,9 @@ test("unit workspace concurrency reserves the full worker budget for heavy works
assert.equal(desktop.tiers.unit.execution, "exclusive");
assert.deepEqual(desktop.tiers.unit.command.args, [
"run",
- `--pool=${nodeWebstorageEnabled() ? "forks" : "threads"}`,
+ // win32 pins forks: threads segfaults the desktop suite there, and the
+ // LaunchServices churn that threads exists to avoid is macOS-only.
+ `--pool=${nodeWebstorageEnabled() || process.platform === "win32" ? "forks" : "threads"}`,
`--maxWorkers=${desktopUnitWorkerCount()}`,
]);
assert.equal(desktopUnitWorkerCount(1), 1);
@@ -197,10 +199,15 @@ test("unit tier pins an explicit vitest pool, forks only by documented exception
// registry -> no frontmost app -> dead keyboard, no menu bar, vanishing Dock
// tiles). A workspace added later must not silently inherit that churn, and
// opting back into forks must be a deliberate edit to this list.
- // Desktop's entry is conditional: it only stays on forks on a Node whose
- // webstorage globals force the execArgv that worker threads cannot take.
+ // Desktop's entry is conditional: it stays on forks on a Node whose
+ // webstorage globals force the execArgv that worker threads cannot take,
+ // and on win32, where threads segfaults the suite outright (native addon
+ // finalizers crashing in isolate teardown) and no launchservicesd exists
+ // for the churn to hurt.
const forksByException = [
- ...(nodeWebstorageEnabled() ? ["apps/desktop"] : []),
+ ...(nodeWebstorageEnabled() || process.platform === "win32"
+ ? ["apps/desktop"]
+ : []),
"packages/maker-core",
];
const unpinned = [];
diff --git a/scripts/test-workspaces.config.mjs b/scripts/test-workspaces.config.mjs
index 550e586191..86726b5b3d 100644
--- a/scripts/test-workspaces.config.mjs
+++ b/scripts/test-workspaces.config.mjs
@@ -17,13 +17,21 @@ const vitestBin = (...args) => ({ type: 'packageBin', bin: 'vitest', args });
// Not everything moves. The heavy manual tiers (db, migration, git-integration)
// stay on the default pool: they bootstrap runtime assets and drive real
// Git/SQLite subprocesses, and none sits on the PR gate path. A workspace also
-// opts out when its tests cannot survive a worker thread; both known blockers
+// opts out when its tests cannot survive a worker thread; the known blockers
// are recorded at their call site below — desktop needs the webstorage flag on a
// Node that installs those globals, and the flag cannot coexist with worker
// threads (scripts/shared/node-webstorage.mjs), while maker-core fakes HOME,
// which a worker cannot see because `process.env` there is a thread-local copy
// while `os.homedir()` reads the real environment through libuv.
//
+// win32 opts desktop out wholesale: on Windows (Node 24.14.1, 2026-07-30) the
+// desktop suite under threads segfaulted the whole vitest process (exit 139)
+// on 2 of 2 runs — same native-addon-finalizer-in-isolate-teardown crash
+// class node-webstorage.mjs documents, only without execArgv in play — while
+// forks passed 15651 tests twice in a row. The churn this pool exists to
+// avoid is a LaunchServices problem; Windows has no launchservicesd, so forks
+// costs it nothing.
+//
// Keep every opt-out listed in the pool regression test, and keep the list
// short: at 1330 of this tier's 1845 files, desktop alone decides whether the
// churn is a trickle or back to where it started.
@@ -101,9 +109,14 @@ export default {
// what local dev and CI run, the flag is a no-op, so this suite's 1330
// files take threads and stop spawning a process each. On a
// webstorage-enabled Node the flag wins and the suite stays on forks.
+ // win32 stays on forks unconditionally — threads segfaults there and
+ // the churn threads exists to avoid is macOS-only (see the pool note
+ // at the top of this file).
command: unitVitestCommand(
desktopUnitWorkerCount(),
- nodeWebstorageEnabled() ? 'forks' : 'threads',
+ nodeWebstorageEnabled() || process.platform === 'win32'
+ ? 'forks'
+ : 'threads',
),
exclude: [
'**/*.git-integration.test.ts',