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

Error when closing channel in 0.5.0 #301

Closed
dmcquay opened this issue Nov 3, 2016 · 3 comments
Closed

Error when closing channel in 0.5.0 #301

dmcquay opened this issue Nov 3, 2016 · 3 comments

Comments

@dmcquay
Copy link

dmcquay commented Nov 3, 2016

When I try to close a channel directly, I get the following error:

Unhandled rejection TypeError: Cannot read property 'closeBecause' of undefined
at /home/dev/repos/ps-messaging-node/node_modules/amqplib/lib/channel_model.js:77:16
at tryCatcher (/home/dev/repos/ps-messaging-node/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.fromNode.Promise.fromCallback (/home/dev/repos/ps-messaging-node/node_modules/bluebird/js/release/promise.js:179:30)
at Channel.C.close (/home/dev/repos/ps-messaging-node/node_modules/amqplib/lib/channel_model.js:76:18)
at Timeout.setTimeout (/home/dev/repos/ps-messaging-node/test.js:33:15)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)

If I close the connection only, it works fine. Here is code to reproduce the error. As far as I can tell, calling connection.close will suit my needs, but the docs indicate that channel.close should still work, so I thought you might want to fix that.

'use strict'

const amqp = require('amqplib')

const username = 'guest'
const password = 'guest'
const host = 'localhost'
const queueName = 'test'

const amqpUrl = `amqp://${username}:${password}@${host}`

let conn, channel

amqp.connect(amqpUrl)
  .then(_conn => {
    conn = _conn
    return conn.createChannel()
  })
  .then(_channel => {
    channel = _channel
    channel.consume(queueName, (message) => {
      console.log('got a message', message)
    })

    setTimeout(() => {
      console.log('closing')

      // this works fine
      // conn.close()
      //   .then(() => console.log('done closing'))

      // this causes an error
      channel.close()
        .then(() => conn.close())
        .then(() => console.log('done closing'))
    }, 200)
  })
@ismriv
Copy link

ismriv commented Nov 4, 2016

I'm reproducing the same issue. Going back to 0.4.x for the time being...

@nfantone
Copy link
Contributor

nfantone commented Nov 5, 2016

This was already reported and fixed. It's still unreleased, though.

Please, search before opening a new issue.

@dmcquay
Copy link
Author

dmcquay commented Nov 9, 2016

Closing per nfantone's comment.

@dmcquay dmcquay closed this as completed Nov 9, 2016
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

3 participants