HarperFast / HarperFast/harper
test:unit:main hangs/flakes on macOS: applicationSpawn.test.js never finishes, EntryHandler.test.js first test times out ~4/6
- Dominant language
- JavaScript
- Stars
- 89
- Forks
- 10
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 200
Description
## Summary
Two `test:unit:main` files cannot be relied on locally on macOS, measured on pristine `origin/main` (`1a5067e1b`) with Node 24.19 and a freshly installed `node_modules` (including `@harperfast/rocksdb-js-darwin-arm64@2.8.0`):
- `unitTests/components/applicationSpawn.test.js` **hangs indefinitely** after the `nonInteractiveSpawn` process-group tests. The last test to report is "accepts a Windows taskkill miss only when the process tree is independently gone"; mocharc's `timeout: 0` means the run never ends, so `npm run test:unit:main` never prints a summary (it was killed at 1700 s twice; the file alone never finished inside 240 s).
- `unitTests/components/EntryHandler.test.js` — its first test, "should instantiate and emit events for adding and removing files and directories", **times out in ~4 of 6 runs** (`--timeout 20000` to make the hang visible; 39 of 40 tests pass). The other 39 pass every time, so this looks like the chokidar/FSEvents warm-up race on a fresh process rather than a logic failure.
Both files are identical between `main` and the branch I was verifying (#2377), and the failure rates matched exactly on both (4/6 and 4/6), so this is the platform, not a regression. Linux CI is green on the same files.
## Impact
Anyone running the `main` gate on a Mac gets no summary at all (the hang) and cannot tell a real failure from the flake. Local workaround: exclude the two files (`--exclude unitTests/components/applicationSpawn.test.js --exclude unitTests/components/EntryHandler.test.js`) and rely on CI for them.
## Suggested fix shape
- `applicationSpawn.test.js`: bound the process-tree waits on non-Linux (the Linux `/proc` scan paths are platform-specific by design; on Darwin the wait appears to have no exit condition), or skip the Linux-only group with `this.skip()` on `process.platform !== 'linux'`.
- `EntryHandler.test.js`: wait for the chokidar `ready` event (or a first no-op event) before touching the tree in the first test, and give the file a real mocha timeout so a hang fails instead of stalling the gate.
Contributor guide
Research direction
Start by running the two named files, unitTests/components/applicationSpawn.test.js and unitTests/components/EntryHandler.test.js, with the reported Mocha timeout settings on macOS. Inspect the nonInteractiveSpawn process-group waits and the first EntryHandler test's chokidar setup, including the suggested Linux-only and ready-event paths. Done means both files finish reliably on macOS and hangs fail with a bounded timeout rather than stalling the test gate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- operating-systems, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100