hunterloftis / jackrabbit

Simple AMQP / RabbitMQ job queues for node based on amqplib
292 stars 65 forks source link

use Promise constructor instead of defer() #44

Closed naartjie closed 6 years ago

naartjie commented 8 years ago

fix for #43

JAertgeerts commented 8 years ago

+1

shnist commented 8 years ago

This fix resolves an error I'm experiencing when initialising JackRabbit:

events.js:85
      throw er; // Unhandled 'error' event
            ^
TypeError: undefined is not a function
    at bindKey (/Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/lib/exchange.js:100:32)
    at Array.map (native)
    at bindKeys (/Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/lib/exchange.js:96:31)
    at EventEmitter.<anonymous> (/Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/lib/exchange.js:76:9)
    at EventEmitter.g (events.js:199:16)
    at EventEmitter.emit (events.js:129:20)
    at onQueue (/Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/lib/queue.js:133:13)
    at /Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/node_modules/amqplib/lib/callback_model.js:59:7
    at /Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/node_modules/amqplib/lib/callback_model.js:74:5
    at reply (/Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/node_modules/amqplib/lib/channel.js:100:16)
    at Channel.C.accept (/Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/node_modules/amqplib/lib/channel.js:433:12)
    at Connection.mainAccept [as accept] (/Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/node_modules/amqplib/lib/connection.js:63:33)
    at Socket.go (/Volumes/Data/Users/aarfaber/Sites/trace-engine/server/src/node_modules/jackrabbit/node_modules/amqplib/lib/connection.js:474:48)
    at Socket.emit (events.js:104:17)
    at emitReadable_ (_stream_readable.js:424:10)
    at emitReadable (_stream_readable.js:418:7)

probably related?

platdesign commented 8 years ago

Had the same issue, investigated a bit and yes: Jackrabbit should support es6 promise. But the real problem is, that some modules overwrite global.Promise with an es6-shim. To prevent this you can do a little workaround before any module is loaded:

let globalPromise = global.Promise;
Object.defineProperty(global, 'Promise', {
  get: () => globalPromise,
  set: (a) => a
});

Not the best solution but ensures using native Promise constructor in your whole code.

matmar10 commented 6 years ago

Merged in #84 which has latest changes in order to run CI tests.