Skip to content

Reconsider making mappingHint's default mapper wrap in an array. #360

@vqvu

Description

@vqvu

Some background:
#247 added mappingHint to wrapCallback. At the time, we thought that the default behavior should wrap multiple arguments to the callback in an array, but this was not backwards compatible, so we decided to delay until 3.0 and added a note in the docs warning of the impending change.

I'm not so sure this default behavior is a good thing anymore. See petkaantonov/bluebird#307 for the issues bluebird (and Q) have had with this default behavior breaking promisified functions. Basically, the following cases can happen

  1. Library writer adds an extra argument to the callback. From their standpoint, this is not a breaking change, but it causes wrapCallback to push an array instead.
  2. Library writer normally fires the callback with two arguments, but adds a code path that only does it with one (e.g., cb(null, value) instead of cb(null, value, null)). The intention is that the second value should be null. This is a common Javascript pattern, but it causes wrapCallback to switch between pushing an array and not practically willy-nilly. This is very bad.

I suggest we take out the wording in the mappingHint docs and just ask people to specify a mappingHint when they need to.

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