Skip to content

Commit db408b3

Browse files
fix(test): re-arm assertion must not race macOS bringing the stream up
fs.watch starts its FSEvents stream on another thread, so the single write that followed the re-arm could be missed outright rather than merely delayed, making the test measure how promptly the watch recovers instead of whether it did.
1 parent ba07d41 commit db408b3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/bindings/nodejs/test/queue.test.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,20 @@ describe('bounded queue under real filesystem pressure', () => {
176176
'rescanRequired'
177177
);
178178

179-
// The point of re-arming: the stream is still live afterwards.
180-
fs.writeFileSync(path.join(dir, 'after-the-fault.js'), 'x');
179+
// The point of re-arming: the stream is still live afterwards. Written repeatedly under a
180+
// fresh name rather than once, because macOS brings the replacement stream up on another
181+
// thread and a single write racing that can be missed outright rather than merely delayed --
182+
// which would make this assert how promptly the watch re-arms, not whether it did.
183+
let attempt = 0;
181184
await waitFor(
182185
() => {
186+
fs.writeFileSync(path.join(dir, `after-the-fault-${(attempt += 1)}.js`), 'x');
183187
for (let event = watcher.poll(); event; event = watcher.poll()) {
184-
if (event.path.endsWith('after-the-fault.js')) return true;
188+
if (event.path.includes('after-the-fault')) return true;
185189
}
186190
return false;
187191
},
188-
{ message: 'nothing was reported after the watch was re-armed' }
192+
{ interval: 100, message: 'nothing was reported after the watch was re-armed' }
189193
);
190194
} finally {
191195
watcher.stop();

0 commit comments

Comments
 (0)