我正在使用bluebird2.x。
我正在打电话给包装在诺言中的卡夫卡。如果消息已发布,则承诺将得到解决。如果对kafka的调用失败,则该承诺将被拒绝。
这是导致错误的代码片段-
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);
})
});
})
stacktrace如下
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)
关于什么可能有什么问题的任何建议?
最佳答案
错误在第98行引发,肯定是由于未在Promise之前使用new。
关于node.js - TypeError:无法设置未定义的属性“_bitField”(Bluebird库),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41660067/