Skip to content

Broken API Contract #9

@sjones6

Description

@sjones6

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions