Skip to content

Commit c09c710

Browse files
fix(server): update fff to stop runaway watcher rescans
fff-node 0.9.4 starts a full workspace rescan on any large file-event batch, overflow, FSEvents rescan flag, or ignore-file change, with no rate limit. On large non-git roots under active development this keeps the backend at 60-190% CPU. fff 0.10.3 added a rescan throttle; 0.11.0 is the current release. 0.11.0 ships separate CJS and ESM builds, so the patch now routes `require` to the ESM build (one module instance for the server and its tests) and carries the asar.unpacked binary lookup over to dist/index.js. Refs #14536 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 921cb3c commit c09c710

7 files changed

Lines changed: 104 additions & 96 deletions

File tree

‎apps/server/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@anthropic-ai/claude-agent-sdk": "^0.3.276",
2727
"@effect/platform-node": "catalog:",
2828
"@effect/platform-node-shared": "catalog:",
29-
"@ff-labs/fff-node": "0.9.4",
29+
"@ff-labs/fff-node": "0.11.0",
3030
"@napi-rs/keyring": "^1.3.0",
3131
"@opencode-ai/sdk": "^1.3.15",
3232
"diff": "8.0.3",

‎patches/@[email protected]‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
diff --git a/package.json b/package.json
2+
index e000a78..8432546 100644
3+
--- a/package.json
4+
+++ b/package.json
5+
@@ -11,7 +11,7 @@
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"import": "./dist/index.js",
9+
- "require": "./dist/index.cjs",
10+
+ "require": "./dist/index.js",
11+
"default": "./dist/index.js"
12+
},
13+
"./package.json": "./package.json"
14+
diff --git a/dist/index.js b/dist/index.js
15+
index 7c1d722..1d0bc27 100644
16+
--- a/dist/index.js
17+
+++ b/dist/index.js
18+
@@ -1,7 +1,7 @@
19+
// src/binary.ts
20+
import { existsSync, readFileSync } from "fs";
21+
import { createRequire } from "module";
22+
-import { dirname, join } from "path";
23+
+import { dirname, join, sep } from "path";
24+
import { fileURLToPath } from "url";
25+
26+
// src/platform.ts
27+
@@ -120,6 +120,16 @@ function getPackageDir() {
28+
function binaryExists() {
29+
return findBinary() !== null;
30+
}
31+
+function resolveUnpackedAsarPath(binaryPath) {
32+
+ const pathSegments = binaryPath.split(sep);
33+
+ const asarIndex = pathSegments.findLastIndex((segment) => segment.endsWith(".asar"));
34+
+ if (asarIndex === -1) {
35+
+ return binaryPath;
36+
+ }
37+
+ pathSegments[asarIndex] = `${pathSegments[asarIndex]}.unpacked`;
38+
+ const unpackedPath = pathSegments.join(sep);
39+
+ return existsSync(unpackedPath) ? unpackedPath : binaryPath;
40+
+}
41+
function resolveFromNpmPackage() {
42+
const packageName = getNpmPackageName();
43+
try {
44+
@@ -128,7 +138,7 @@ function resolveFromNpmPackage() {
45+
const packageDir = dirname(packageJsonPath);
46+
const binaryPath = join(packageDir, getLibFilename());
47+
if (existsSync(binaryPath)) {
48+
- return binaryPath;
49+
+ return resolveUnpackedAsarPath(binaryPath);
50+
}
51+
} catch {
52+
}

‎patches/@[email protected]‎

Lines changed: 0 additions & 53 deletions
This file was deleted.

‎pnpm-lock.yaml‎

Lines changed: 48 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ patchedDependencies:
184184
185185
186186
187-
"@ff-labs/fff-node@0.9.4": patches/@ff-labs__fff-node@0.9.4.patch
187+
"@ff-labs/fff-node@0.11.0": patches/@ff-labs__fff-node@0.11.0.patch
188188
"@legendapp/[email protected]": patches/@[email protected]
189189
"@pierre/[email protected]": patches/@pierre%[email protected]
190190
"@react-native-ai/[email protected]": patches/@[email protected]

‎scripts/build-desktop-artifact.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
14171417
primaryProbe.args[4],
14181418
path.join(
14191419
fixture.packagedAppDir,
1420-
"resources/server.asar/node_modules/@ff-labs/fff-node/dist/src/index.js",
1420+
"resources/server.asar/node_modules/@ff-labs/fff-node/dist/index.js",
14211421
),
14221422
);
14231423
assert.equal(primaryProbe.options.cwd, fixture.packagedAppDir);

‎scripts/build-desktop-artifact.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,7 @@ export const verifyWindowsPrimaryFffNativeLoad = Effect.fn(
30533053
});
30543054
const fffEntryPath = path.join(
30553055
input.asarPath,
3056-
"node_modules/@ff-labs/fff-node/dist/src/index.js",
3056+
"node_modules/@ff-labs/fff-node/dist/index.js",
30573057
);
30583058
const probeEnv = { ...process.env };
30593059
delete probeEnv.ELECTRON_NO_ASAR;

0 commit comments

Comments
 (0)