hunterloftis / jackrabbit

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

Not handling ETIMEDOUT error exception #65

Open CodeStrumpet opened 7 years ago

CodeStrumpet commented 7 years ago

If this is not the best place to post this, please let me know and my apologies. I am experiencing an issue when I put my computer to sleep for a longish period of time and then reopen it. I am leaving the node process running and when I wake it up I see the error below.

I am wondering where I should be handling this error event. I have pasted the code I use to instantiate jackrabbit below, I would have thought this error would have passed through the error handler I setup but it doesn't seem to. Any ideas where I should be listening for this error?

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: read ETIMEDOUT
    at exports._errnoException (util.js:1036:11)
    at TCP.onread (net.js:564:26)
  const jackrabbit = require('jackrabbit');
  this.queue = jackrabbit(rabbitUrl)
    .on('connected', () => {
      console.info({ type: 'info', msg: 'connected', service: 'rabbitmq' });
      ready();
    })
    .on('error', (err) => {
      console.error({ type: 'error', msg: err, service: 'rabbitmq' });
    })
    .on('disconnected', () => {
      console.warn({ type: 'error', msg: 'disconnected', service: 'rabbitmq' });
      lost();
    });
anidhya commented 5 years ago

Add something like this in your code.

process.on('uncaughtException', err => { console.log("uncaughtException"); console.log(err); process.exit(); });