Skip to content

Commit eac57e9

Browse files
committed
Add worker.unref() to prevent test hangs
The worker pool was causing Jest to hang because the worker thread prevented Node from exiting. Using unref() allows Node to exit even if the worker is still running, which is safe since the worker is lazily created and terminated on app quit. This fixes the integration test failures where tests would timeout waiting for the process to exit.
1 parent a0f641d commit eac57e9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/services/tokenizerWorkerPool.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class TokenizerWorkerPool {
4747
this.worker = new Worker(workerPath);
4848
this.isTerminating = false;
4949

50+
// Allow Node to exit even if worker is still running (important for tests)
51+
this.worker.unref();
52+
5053
this.worker.on("message", (response: TokenizeResponse) => {
5154
this.handleResponse(response);
5255
});

0 commit comments

Comments
 (0)