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

Incompatibility with bluebird 1.0.2 (no method '_fulfill') #176

Closed
kbanman opened this Issue Feb 5, 2014 · 7 comments

Comments

Projects
None yet
4 participants
@kbanman

kbanman commented Feb 5, 2014

Updating bluebird in my app to "latest" (v1.0.2) results in this error:

/my/project/node_modules/knex/node_modules/bluebird/js/main/promise.js:900
            if (isFulfilled) promise._fulfill(value);
                                     ^
TypeError: Object -1 has no method '_fulfill'
    at Promise$_settlePromiseAt [as _settlePromiseAt] (/my/project/node_modules/knex/node_modules/bluebird/js/main/promise.js:900:38)
    at Promise$_fulfillPromises [as _fulfillPromises] (/my/project/node_modules/knex/node_modules/bluebird/js/main/promise.js:976:14)
    at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/my/project/node_modules/knex/node_modules/bluebird/js/main/async.js:63:12)
    at Async$consumeFunctionBuffer (/my/project/node_modules/knex/node_modules/bluebird/js/main/async.js:36:14)
    at process._tickCallback (node.js:415:13)
    at process._tickFromSpinner (node.js:390:15)

It works fine in Bluebird 1.0.1.

I will try to reproduce this with a minimal example, but I'm fairly certain it's an incompatibility between knex and bluebird, as two of my knex-powered apps did this.

@kbanman

This comment has been minimized.

kbanman commented Feb 5, 2014

Okay, I tracked it down in my code:

function getServices() {
  return Knex.db('services').select();
}
getServices().then(function (services) {
  // ..
});

The above resulted in the error, while adding a .then() or .exec to the knex line fixes it.
I suppose the way I was doing it is invalid, but still interesting that it works in one version of bluebird and not the next.

@kbanman kbanman closed this Feb 5, 2014

@kbanman

This comment has been minimized.

kbanman commented Feb 5, 2014

Okay, still having related problems. Here is a script that replicates the error:


var Promise = require('bluebird');
var Knex = require('knex');

var db = Knex.initialize({
    client: 'sqlite3',
    connection: { filename: './db.sqlite' }
});

function saveResult() {
    return db('test')
        .insert({ foo: 'bar' })
        .then(function () {
            console.log('inserted');
        });
}

function promiseMe() {
    return Promise.resolve();
}

promiseMe().then(function () {
    return saveResult();
});

@kbanman kbanman reopened this Feb 5, 2014

@kbanman

This comment has been minimized.

kbanman commented Feb 5, 2014

So it seems to me that the new version of bluebird does not chain with the promises returned by knex.

@johanneslumpe

This comment has been minimized.

Collaborator

johanneslumpe commented Feb 5, 2014

Not sure if this helps, but if you restructure your code like this, the error goes away:

var Promise = require('bluebird');
var Knex = require('./knex/knex');

var db = Knex.initialize({
    client: 'sqlite3',
    connection: { filename: './db.sqlite' }
});

function saveResult() {
    return db('test')
        .insert({ foo: 'bar' });
}

function promiseMe() {
    return Promise.resolve();
}

promiseMe().then(function () {
    return saveResult();
})
.then(function () {
  console.log('inserted');
})
.catch(function (err) {
  console.log(err);
});

Can't look into this further at the moment, but I might have time later on.

@tgriesser

This comment has been minimized.

Owner

tgriesser commented Feb 5, 2014

@petkaantonov I haven't looked at it yet, but this sounds like a strange error... Any ideas what might have happened here between 1.0.1 and 1.0.2?

@tgriesser

This comment has been minimized.

Owner

tgriesser commented Feb 5, 2014

All right, if you grab the latest knex, it requires bluebird 1.0.x which should fix this, until petkaantonov/bluebird#93 is fixed.

@tgriesser tgriesser closed this Feb 5, 2014

@tgriesser tgriesser added bug labels Feb 5, 2014

@petkaantonov

This comment has been minimized.

petkaantonov commented Feb 5, 2014

I will get home in a few hours and will investigate this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment