waterlinejs / rabbitmq-adapter

RabbitMQ Adapter for Sails and Waterline
Other
17 stars 2 forks source link

Starting a persistence worker with jobs already in a queue causes an error #5

Closed ryanwilliamquinn closed 9 years ago

ryanwilliamquinn commented 9 years ago
/Users/rquinn/repos/PathwaysAPI/node_modules/sails-mongo/lib/adapter.js:278
      collection.insert(data, function(err, results) {
                ^
TypeError: Cannot read property 'insert' of undefined
    at Object.module.exports.adapter.create (/Users/rquinn/repos/PathwaysAPI/node_modules/sails-mongo/lib/adapter.js:278:17)
    at WorkerSocket.<anonymous> (/Users/rquinn/repos/sails-rabbitmq/dist/handlers/persistence.js:69:33)
    at WorkerSocket.emit (events.js:107:17)
    at WorkerSocket.Readable.read (_stream_readable.js:373:10)
    at flow (_stream_readable.js:750:26)
    at resume_ (_stream_readable.js:730:3)
    at _stream_readable.js:717:7
    at process._tickDomainCallback (node.js:381:11)
tjwebb commented 9 years ago

@ryanwilliamquinn I can't reproduce this locally. e.g. if I leave 5 messages in the persistence queue, they all are popped off and persisted once the persistence handler fires up.

My guess is that there's a race condition, where the rabbitmq adapter loads first, and it tries to use the persistence connection before it's setup and connected. I'm going to try to listen for hook:orm:loaded and hope that fixes it.