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

Broken API Contract #9

Open
sjones6 opened this issue Apr 5, 2019 · 0 comments
Open

Broken API Contract #9

sjones6 opened this issue Apr 5, 2019 · 0 comments

Comments

@sjones6
Copy link

sjones6 commented Apr 5, 2019

When calling exit hook, like so:

exitHook(cb => { /* do something on exit */ })

cb may not be a function depending on how the async-exit-hook routine is entered. If it's entered with an uncaught error, then it's called with 2 params and the second is the callback.

if (exit && hook.length > syncArgCount) {
  // Hook is async, expects a finish callback
  waitingFor++;

  if (err) {
    // Pass error, calling uncaught exception handlers
   return hook(err, stepTowardExit); // call called with 2 params
  }
  return hook(stepTowardExit); // <-- called with 1 param
}

This would be easy to fix by simply changing the second to:

return hook(null, stepTowardExit);

Because this is a breaking change to the API, it probably warrants a major version upgrade.

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

No branches or pull requests

1 participant