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

Improve worker exited unexpectedly error #58

Merged
merged 1 commit into from
Mar 12, 2019

Conversation

stefanpenner
Copy link
Collaborator

@stefanpenner stefanpenner commented Mar 11, 2019

When a worker exits unexpectedly, it can be tricky to figure out why.
To improve debugging, I've added some additional information to the existing error message:

  • the status code or signal code
  • that workerpools script
  • spawnargs
  • spawnfile
  • stdout
  • stderr

example output:

Error: Workerpool Worker terminated Unexpectedly
    exitCode: `12`
    workerpool.script: `/Users/spenner/src/josdejong/workerpool/lib/worker.js`
    spawnArgs: `/usr/local/Cellar/node/11.10.0/bin/node,--inspect=43210,/Users/spenner/src/josdejong/workerpool/lib/worker.js`
    spawnfile: `/usr/local/Cellar/node/11.10.0/bin/node`
    stdout: `null`
    stderr: `null`

    at ChildProcess.<anonymous> (/Users/spenner/src/josdejong/workerpool/lib/WorkerHandler.js:263:13)
    at ChildProcess.emit (events.js:197:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)

@stefanpenner
Copy link
Collaborator Author

I suspect the issue is, we have 1 incrementing ID per pool

debugPort: this.debugPortStart + workers.length,
so if we have 2 pools they will conflict.

@stefanpenner
Copy link
Collaborator Author

Some ideas:

  • don't propagate --inspector ports to child processes (likely not a great idea)
  • partition the child process inspector ports like: this.debugPortStart = (options.debugPortStart || 43210) + (1000 * POOL_COUNT); <-- confirmed this works
  • have a shared port allocator, that ensures all provided ports are unique and reclaimed during terminate <-- likely the best idea

stefanpenner added a commit to stefanpenner/workerpool that referenced this pull request Mar 12, 2019
stefanpenner added a commit to stefanpenner/workerpool that referenced this pull request Mar 12, 2019
stefanpenner added a commit to stefanpenner/workerpool that referenced this pull request Mar 12, 2019
@josdejong
Copy link
Owner

Thanks for improving the error reporting! 👍

@josdejong josdejong merged commit 447c258 into josdejong:master Mar 12, 2019
@stefanpenner stefanpenner deleted the worker-exited-messaging branch March 12, 2019 21:14
stefanpenner added a commit that referenced this pull request Mar 14, 2019
[Fixes #58] Allocate Debug ports safely, so multiple pools don’t acci…
maybephilipp pushed a commit to maybephilipp/workerpool that referenced this pull request Sep 27, 2020
Co-authored-by: Aleksey Gerasimov <starostin13@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants