andywer / andywer/threads.js

Should really not install signal handlers that call process.exit with no way to opt out

Offen
#388 9 Kommentare 5 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
TypeScript
Sterne
3.5k
Forks
173
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Because threads.js installs it's own signal handlers for `SIGINT` and `SIGTERM` and those handlers call `process.exit`, that means it's impossible to ensure that whatever other cleanup needs to happen when terminated actually happens. Because of this libraries should not generally install signal handlers at all, leaving this up to the application code. This is why the [tiny-worker faq](https://github.com/avoidwork/tiny-worker#faq) mentioned in the code is a FAQ, because it would be unwise for tiny-worker to install those signal handlers itself, the developer using tiny-worker needs to do that at whatever point is appropriate for their application.

I'll attempt to find the time this afternoon to put together a PR, but thought I should at least mention this problem in case anyone else is having issues with cleanup not happening. Personally, my opinion is that a library like this shouldn't be adding signal handlers at all, though you could provide a method that the developer could call to opt-in to this feature. If you intend to keep the signal handlers enabled by default though, we need at a minimum some way to opt out of that.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.