Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling connection.close may return a promise which never resolves #181

Closed
mike-zorn opened this issue Sep 1, 2015 · 1 comment
Closed

Comments

@mike-zorn
Copy link

When calling connection.close on a connection which has error'd, a promise which never resolves is returned. To reproduce, execute the following and close the created connection via the RabbitMQ management plugin.

var amqp = require('amqplib')
var conn = amqp.connect()

conn.then(function (connection) {
  connection.on('error', function () {
    console.log('error')
    connection.close()
    .then(
      console.log.bind(console, 'ok'),
      console.log.bind(console, 'fail')
    )
  })
})

setInterval(function () {}, 1000)

You'll see that ok or fail are never logged which indicates that connection.close() never resolved.

Admittedly, this example is a bit contrived, but it's just a simplification of what we do in production: listen to uncaughtException and attempt to close any connections before the process exits.

@squaremo
Copy link
Collaborator

(github auto-closed this because I mentioned the issue in the commit message -- please reopen if you find it does not solve your problem!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants