Skip to content

Commit 35bec58

Browse files
committed
feat(core): bump default watch aggregateTimeout to 100ms; drop fixture overrides
rstest used to default rspack's `watchOptions.aggregateTimeout` to 5ms (see Watching.ts comment). That was safe under the chokidar watcher where the aggregate is just a watchpack-level event-merging window, but is too aggressive under the rspack native watcher on macOS: the runtime stats the changed file ~5ms after the FSEvent arrives, well inside the vnode-cache settling window, and reads stale content. The resulting "No test files need re-run" is the failure mode addressed by this PR. Set the default to 100ms in the rstest plugin so every watch project inherits a sane value without each fixture wiring its own override. Drop the per-fixture `tools.rspack.watchOptions.aggregateTimeout: 10` that was added long ago (chokidar era). Individual cases that need a different value can still set it via `tools.rspack.watchOptions` and the user value wins through rsbuild's regular merge order.
1 parent f1226f2 commit 35bec58

7 files changed

Lines changed: 12 additions & 44 deletions

File tree

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
import { defineConfig } from '@rstest/core';
22

3-
export default defineConfig({
4-
tools: {
5-
rspack: {
6-
watchOptions: {
7-
aggregateTimeout: 100,
8-
},
9-
},
10-
},
11-
});
3+
export default defineConfig({});
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
import { defineConfig } from '@rstest/core';
22

3-
export default defineConfig({
4-
tools: {
5-
rspack: {
6-
watchOptions: {
7-
aggregateTimeout: 100,
8-
},
9-
},
10-
},
11-
});
3+
export default defineConfig({});

e2e/watch/fixtures-setup/rstest.config.mts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,4 @@ export default defineConfig({
44
passWithNoTests: true,
55
setupFiles: ['./rstest.setup.ts'],
66
exclude: ['**/node_modules/**', '**/dist/**'],
7-
tools: {
8-
rspack: {
9-
watchOptions: {
10-
aggregateTimeout: 100,
11-
},
12-
},
13-
},
147
});

e2e/watch/fixtures-shortcuts/rstest.config.mts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,4 @@ process.stdin.setRawMode = () => process.stdin;
66
export default defineConfig({
77
reporters: ['default'],
88
disableConsoleIntercept: true,
9-
tools: {
10-
rspack: {
11-
watchOptions: {
12-
aggregateTimeout: 100,
13-
},
14-
},
15-
},
169
});
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
import { defineConfig } from '@rstest/core';
22

3-
export default defineConfig({
4-
tools: {
5-
rspack: {
6-
watchOptions: {
7-
aggregateTimeout: 100,
8-
},
9-
},
10-
},
11-
});
3+
export default defineConfig({});

packages/core/src/core/plugins/entry.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@ export const pluginEntryWatch: (params: {
5656
};
5757

5858
config.watchOptions ??= {};
59-
// FIXME: Temporarily default to 5 to debounce rerun in watch mode.
60-
config.watchOptions.aggregateTimeout = 5;
59+
// Default aggregate window for watch-mode rerun debouncing. On macOS
60+
// with the rspack native watcher this also needs to be long enough
61+
// for the FSEvent → vnode cache invalidation cycle to complete
62+
// before rspack stats the changed file (otherwise the rebuild reads
63+
// stale content and rstest reports "No test files need re-run").
64+
// 100 ms is the minimum value that survives macos-14 GHA runners.
65+
// User configs can override via `tools.rspack.watchOptions`.
66+
config.watchOptions.aggregateTimeout = 100;
6167
// TODO: rspack should support `(string | RegExp)[]` type
6268
// https://github.com/web-infra-dev/rspack/issues/10596
6369
config.watchOptions.ignored = castArray(

packages/core/tests/core/__snapshots__/rsbuild.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ exports[`prepareRsbuild > should generate rspack config correctly in watch mode
22562256
},
22572257
"target": "node",
22582258
"watchOptions": {
2259-
"aggregateTimeout": 5,
2259+
"aggregateTimeout": 100,
22602260
"ignored": [
22612261
"**/.git",
22622262
"**/node_modules",

0 commit comments

Comments
 (0)