gpt4 book ai didi

node.js - 类型错误 : Cannot set property '_bitField' of undefined (Bluebird library)

转载 作者:太空宇宙 更新时间:2023-11-03 23:28:00 24 4
gpt4 key购买 nike

我使用的是 bluebird 2.x。

我正在给 kafka 打电话,它包含在一个 promise 中。如果消息被发布, promise 就得到解决。如果对 kafka 的调用失败,promis 就会被拒绝。

这是导致错误的代码段 -

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);
})
});
})

堆栈跟踪如下

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 - 类型错误 : Cannot set property '_bitField' of undefined (Bluebird library),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41660067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com