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(desktop): guard Rollup ws interop on Node 24

guyongcf3f13e294c3
diff --git a/dependency-patches/[email protected] b/dependency-patches/[email protected]
index a4a37f8304..a18aeff757 100644
--- a/dependency-patches/[email protected]
+++ b/dependency-patches/[email protected]
@@ -2,6 +2,23 @@ diff --git a/dist/es/shared/node-entry.js b/dist/es/shared/node-entry.js
index 0c67f4b0befbb8af05adc5c4b0216cacbf8c169a..d270a376f10c5da4c36f8579914954c824804522 100644
--- a/dist/es/shared/node-entry.js
+++ b/dist/es/shared/node-entry.js
+@@ -7226,10 +7226,12 @@
+ name: null
+ });
+ return (`${index}${cnst} d${_}=${_}Object.getOwnPropertyDescriptor(e,${_}k);${n}` +
+- `${index}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` +
+- `${index}${t}enumerable:${_}true,${n}` +
+- `${index}${t}get:${_}${left}e[k]${right}${n}` +
+- `${index}});${n}`);
++ `${index}if${_}(d)${_}{${n}` +
++ `${index}${t}Object.defineProperty(n,${_}k,${_}d.get${_}?${_}d${_}:${_}{${n}` +
++ `${index}${t}${t}enumerable:${_}true,${n}` +
++ `${index}${t}${t}get:${_}${left}e[k]${right}${n}` +
++ `${index}${t}});${n}` +
++ `${index}}${n}`);
+ };
+ const copyPropertyLiveBinding = (t, index, { _, cnst, getDirectReturnFunction, n }) => {
+ const [left, right] = getDirectReturnFunction([], {
@@ -16953,6 +16953,14 @@ function resetSourcemapCache(map, sourcemapChain) {
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index bf5831ee54..1b5283e3ed 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -38,7 +38,7 @@ patchedDependencies:
hash: 9442031604caa9cd185e0b2be6867055459fc3a6d2781296027989db098f972d
path: dependency-patches/[email protected]
- hash: 6d3d17b477e7f051a92906a213d0dfafe6a1f32abd24e526ddfb29603b925037
+ hash: 7ef53ca5a7e44d41cdbc0e10ea0475c928bddf13ad769cf15628579d0c4bfc98
path: dependency-patches/[email protected]
importers:
@@ -21697,7 +21697,7 @@ snapshots:
'@rolldown/binding-win32-arm64-msvc': 1.2.8
'@rolldown/binding-win32-x64-msvc': 1.2.8
- [email protected](patch_hash=6d3d17b477e7f051a92906a213d0dfafe6a1f32abd24e526ddfb29603b925037):
+ [email protected](patch_hash=7ef53ca5a7e44d41cdbc0e10ea0475c928bddf13ad769cf15628579d0c4bfc98):
dependencies:
'@types/estree': 1.0.9
optionalDependencies:
@@ -22738,7 +22738,7 @@ snapshots:
fdir: 6.5.0([email protected])
picomatch: 4.0.5
postcss: 8.5.19
- rollup: 4.62.2(patch_hash=6d3d17b477e7f051a92906a213d0dfafe6a1f32abd24e526ddfb29603b925037)
+ rollup: 4.62.2(patch_hash=7ef53ca5a7e44d41cdbc0e10ea0475c928bddf13ad769cf15628579d0c4bfc98)
tinyglobby: 0.2.17
optionalDependencies:
'@types/node': 25.9.5
@@ -22755,7 +22755,7 @@ snapshots:
fdir: 6.5.0([email protected])
picomatch: 4.0.5
postcss: 8.5.19
- rollup: 4.62.2(patch_hash=6d3d17b477e7f051a92906a213d0dfafe6a1f32abd24e526ddfb29603b925037)
+ rollup: 4.62.2(patch_hash=7ef53ca5a7e44d41cdbc0e10ea0475c928bddf13ad769cf15628579d0c4bfc98)
tinyglobby: 0.2.17
optionalDependencies:
'@types/node': 25.9.5
diff --git a/scripts/__tests__/test-workspaces.test.mjs b/scripts/__tests__/test-workspaces.test.mjs
index d4f7c4af43..1386fe3849 100644
--- a/scripts/__tests__/test-workspaces.test.mjs
+++ b/scripts/__tests__/test-workspaces.test.mjs
@@ -6,8 +6,9 @@ import { EventEmitter } from "node:events";
import test from "node:test";
import { fileURLToPath } from "node:url";
import manifest, {
- desktopUnitWorkerCount,
- unitTestShardArgs,
+ desktopUnitWorkerCount,
+ desktopUnitPool,
+ unitTestShardArgs,
} from "../test-workspaces.config.mjs";
import { nodeWebstorageEnabled } from "../shared/node-webstorage.mjs";
import {
@@ -197,7 +198,7 @@ test("unit workspace concurrency reserves the full worker budget for heavy works
"run",
// 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"}`,
+ `--pool=${desktopUnitPool()}`,
`--maxWorkers=${desktopUnitWorkerCount()}`,
...unitTestShardArgs(),
]);
@@ -283,9 +284,7 @@ test("unit tier pins an explicit vitest pool, forks only by documented exception
// finalizers crashing in isolate teardown) and no launchservicesd exists
// for the churn to hurt.
const forksByException = [
- ...(nodeWebstorageEnabled() || process.platform === "win32"
- ? ["apps/desktop"]
- : []),
+ ...(desktopUnitPool() === "forks" ? ["apps/desktop"] : []),
"packages/maker-core",
];
const unpinned = [];
@@ -316,6 +315,13 @@ test("nodeWebstorageEnabled detects the globals that force the webstorage flag",
);
});
+test("desktop unit uses forks on Node 24+ to avoid native finalizer crashes", () => {
+ assert.equal(desktopUnitPool("darwin", "24.18.0", false), "forks");
+ assert.equal(desktopUnitPool("darwin", "22.23.0", false), "threads");
+ assert.equal(desktopUnitPool("win32", "22.23.0", false), "forks");
+ assert.equal(desktopUnitPool("darwin", "25.0.0", true), "forks");
+});
+
test("normalizeRelPath makes path matching independent of host path separators", () => {
assert.equal(
normalizeRelPath("apps\\desktop\\src\\main\\foo.test.ts"),
diff --git a/scripts/test-workspaces.config.mjs b/scripts/test-workspaces.config.mjs
index 6a1746a9ae..4599cbb213 100644
--- a/scripts/test-workspaces.config.mjs
+++ b/scripts/test-workspaces.config.mjs
@@ -24,13 +24,10 @@ const vitestBin = (...args) => ({ type: 'packageBin', bin: 'vitest', args });
// 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.
+// Node 24+ opts desktop out of threads: the suite segfaults during native-addon
+// finalization on macOS as well as Windows, even without the webstorage
+// execArgv. Older Node 22 macOS runs stay on threads to avoid process churn;
+// Windows has no launchservicesd, so it stays on forks regardless of version.
//
// 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
@@ -38,6 +35,15 @@ const vitestBin = (...args) => ({ type: 'packageBin', bin: 'vitest', args });
const UNIT_POOL_DEFAULT = 'threads';
const UNIT_TEST_SHARD_ENV = 'XDT_UNIT_TEST_SHARD';
+export function desktopUnitPool(
+ platform = process.platform,
+ nodeVersion = process.versions.node,
+ webstorageEnabled = nodeWebstorageEnabled(),
+) {
+ const nodeMajor = Number.parseInt(nodeVersion, 10);
+ return webstorageEnabled || platform === 'win32' || nodeMajor >= 24 ? 'forks' : 'threads';
+}
+
/**
* Split every Vitest workspace by the same CI shard so the two Windows jobs
* still form one complete unit gate. The runner adds `passWithNoTests` only
@@ -146,9 +152,7 @@ export default {
// at the top of this file).
command: unitVitestCommand(
desktopUnitWorkerCount(),
- nodeWebstorageEnabled() || process.platform === 'win32'
- ? 'forks'
- : 'threads',
+ desktopUnitPool(),
),
exclude: [
'**/*.git-integration.test.ts',