Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker.exit should set process.exitCode instead of calling process.exit to allow cleanup #429

Open
cha0s opened this issue Feb 7, 2024 · 4 comments

Comments

@cha0s
Copy link

cha0s commented Feb 7, 2024

No description provided.

@josdejong
Copy link
Owner

Ahh, I was not aware of that. Who knows, this may explain some of the issues regarding exiting that we've seen in the past.

For context:

@josdejong
Copy link
Owner

Anyone able to work this out in a PR?

@cha0s
Copy link
Author

cha0s commented Feb 10, 2024

Just as a little context, I encountered this library when working with mocha --parallel which uses workerpool to handle its workers.

This is what I came up with for the mean time to reliably(?) run cleanup tasks from within a worker:

  process.prependListener('message', async (message) => {
    if ('__workerpool-terminate__' === message) {
      // ...
    }
  });

I might be able to get a PR on this soonish, but I would definitely want to familiarize myself a little more with the code than the quick spelunk that led me to bring this issue to your attention.

Thanks for the response!

@josdejong
Copy link
Owner

Thanks for the clarification Ruben! Help working this out in a solution would be very welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants