How to use the amqplib.IllegalOperationError function in amqplib

To help you get started, we’ve selected a few amqplib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taskcluster / taskcluster / libraries / pulse / src / consumer.js View on Github external
const isExpectedError = err => {
  // IllegalOperationError happens when we are draining a broken channel; ignore
  if (err instanceof amqplib.IllegalOperationError) {
    return true;
  }

  // similarly, an error with this text is sent in some failure modes.  See
  // https://github.com/streadway/amqp/issues/409 for a request for a better
  // way to recognize this
  if (err.message.match(/no reply will be forthcoming/)) {
    return true;
  }
};
github taskcluster / taskcluster / libraries / pulse / src / client.js View on Github external
return this.withConnection(async conn => {
      const method = confirmChannel ? 'createConfirmChannel' : 'createChannel';
      const channel = await conn.amqp[method]();

      // any errors on this channel will be handled as exceptions thrown within `fn`,
      // so the events can be ignored
      channel.on('error', () => {});

      try {
        return await fn(channel);
      } finally {
        try {
          await channel.close();
        } catch (err) {
          if (!(err instanceof amqplib.IllegalOperationError)) {
            // IllegalOperationError happens when we are closing a broken
            // channel; any other error trying to close the channel suggests
            // the connection is dead, so mark it failed.
            conn.failed();
          }
        }
      }
    });
  }

amqplib

An AMQP 0-9-1 (e.g., RabbitMQ) library and client.

MIT
Latest version published 20 days ago

Package Health Score

91 / 100
Full package analysis