andywer / andywer/threads.js

pool.terminate hangs when "Timeout: Did not receive an init message from worker" first

Open
#461 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.5k
Forks
173
PR merge metrics
No merged PRs in 30d

Description

I have some code like:

```
let err;
try {
await pool.settled();
} catch (_err) {
err = _err;
} finally {
await pool.terminate(!!err);
}
```

It works when there are no errors, and when there is an "expected" error in one of the threads, but when the error is "Timeout: Did not receive an init message from worker ...", calling terminate hangs. I have the workaround:

```
if (!err?.message?.startsWith('Timeout: Did not receive an init message from worker')) {
await pool.terminate(!!err);
}
```

which works, but it seems like an early exit inside terminate would be appropriate for a case like this. Thoughts?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.