Skip to content

Promise#nodeify should not pass undefined as an explicit argument to a Node.js continuation callback #170

@cantremember

Description

@cantremember

i am seeing this issue in 1.2.1. it's easiest to describe via assertion

'use strict';

var assert = require('assert');
var Promise = require('bluebird');

describe('Promise', function() {
    describe('#nodeify', function() {
        it('receives an undefined result argument', function(done) {
            Promise.resolve().nodeify(function() {
                // a both a null Error and an undefined result are provided.
                assert.equal(2, arguments.length);
                assert.strictEqual(null, arguments[0]);
                assert.strictEqual(undefined, arguments[1]);

                // frameworks such as async will see `undefined` as an actual result value
                //   and honor it accordingly.  there are side-effects in the case of async.waterfall,
                //   where the `callback` provided to a series function will become the 2nd argument,
                //   since the 1st argument is the `undefined` result value handed downstream by #nodeify.
                // it would be more backward-compatible for #nodeify to provide a 1-argument signature --
                //   `(null)` as filler for the missing Error -- to the Node.js continuation callback
                //   when the upstream result value is `undefined`.
                done();
            });
        });
    });
});

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