Files
Dragan Spiridonov 9e314ff383 fix(tests): unblock full unit suite and drop force-exit hack (#396)
The full `npx vitest run tests/unit/` suite was hanging >22 minutes
since v3.9.1 due to a futex deadlock in `@ruvector/router` native NAPI
calls during HNSW VectorDb operations. v3.9.5 already addressed the
root cause by flipping `useNativeHNSW` default from true to false
(commit 3a1d9636). This commit closes the loop by:

1. Fixing the one fallout test introduced by that flag flip:
   `tests/unit/cli/commands/ruvector-commands.test.ts:110` was setting
   `useNativeHNSW: false` to test the (modified) marker, but false is
   now the default, so the marker never appeared. Flipped to `true`.

2. Removing the `tests/setup-worker.ts` `process.exit(0)` force-exit
   hack. It was added as a band-aid when fork workers hung on lingering
   native handles. Since v3.9.3 added the `dispose()` contract on HNSW
   backends and v3.9.5 disabled native HNSW by default, workers now
   exit cleanly on their own. The 5-second main-process safety net in
   `tests/global-teardown.ts` is intentionally kept as a last resort.

Verification (full `tests/unit/`, 505 files):
- Before this PR (with hack):    7m26s, 1 failed,  16308 passed
- After  this PR (no hack):      6m21s, 0 failed,  16309 passed

The 1m05s saved comes from the per-file 2s force-exit delays the hack
was adding, even though the timer was unref'd.

Closes #396

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 15:15:04 +00:00

21 lines
917 B
TypeScript

/**
* Worker-level setup for vitest fork pool.
*
* Previously this file registered an `afterAll` hook that scheduled a
* `process.exit(0)` 2 seconds after the last test in each file, to work
* around fork workers hanging on lingering native handles
* (`@ruvector/router` VectorDb, hnswlib-node, better-sqlite3).
*
* The underlying causes were fixed in:
* - v3.9.3 — `dispose()` contract added to HNSW backends + HnswAdapter.close
* - v3.9.5 — `useNativeHNSW` default flipped to false (futex deadlock fix, #401)
*
* With those fixes the workers exit cleanly on their own, so the
* force-exit safety net is no longer needed. The `tests/global-teardown.ts`
* 5-second main-process safety net is intentionally kept as a last resort.
*
* If you reintroduce a native module that holds handles past `afterAll`,
* fix the dispose path in the module rather than putting the timer back.
*/
export {};