I am using bluebird 3.4.6.
I am making a call to kafka which is wrapped inside a promise. The promise is resolved if the message is published. The promise is rejected if the call to kafka fails.
Here is the piece of code that is causing the error -
redis.get(something)
.then(function() {
return Promise(function(resolve, reject) { // This is Line 98 in the stacktrace
producer.send([
{
topic : "Ganga",
messages : [JSON.stringify({// some object})]
}
], function(err, data) {
if(err) {
logger.error("Error")
logger.error(err);
reject(err);
return;
}
resolve(data);
})
});
})
The stacktrace is as follows
TypeError: Cannot set property '_bitField' of undefined
at <project base path>/index.js:98:20
at bound (domain.js:280:14)
at runBound (domain.js:293:12)
at runCallback (timers.js:649:20)
at tryOnImmediate (timers.js:622:5)
at processImmediate [as _immediateCallback] (timers.js:594:5)
From previous event:
at Server.<anonymous> (<project base path>/index.js:97:10)
at next (<project base path>/node_modules/restify/lib/server.js:912:30)
at f (<project base path>/node_modules/once/once.js:25:25)
at Server.parseBody (<project base path>/node_modules/restify/lib/plugins/body_parser.js:94:13)
at next (<project base path>/node_modules/restify/lib/server.js:912:30)
at f (<project base path>/node_modules/once/once.js:25:25)
at IncomingMessage.done (<project base path>/node_modules/restify/lib/plugins/body_reader.js:121:13)
at IncomingMessage.g (events.js:292:16)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
Any suggestion on what could be wrong?
You're missing new before Promise, but that's not the error I'd expect you to get.
Ran into the same error today when I accidentally did this:
const coroutine = require('bluebird');
coroutine(function* () {
yield foo();
...
});
TypeError: Cannot set property '_bitField' of undefined
at Promise (/<snip>/node_modules/bluebird/js/release/promise.js:70:20)
at ...
(instead of :
const {coroutine} = require('bluebird');
...
)
I ran into this when I did
const Promise = require('bluebird')(); instead of const Promise = require('bluebird/js/release/promise')();.
Most helpful comment
You're missing
newbeforePromise, but that's not the error I'd expect you to get.