amqp-node / amqplib

AMQP 0-9-1 library and client for Node.JS
https://amqp-node.github.io/amqplib/
Other
3.69k stars 474 forks source link

Update channel_model.js #747

Closed NevilDabre closed 7 months ago

NevilDabre commented 11 months ago

Got this error on the production server

(node:64) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fields' of null at Channel.ack (/home/node/node_modules/amqplib/lib/callback_model.js:234:37) at _callee$ (/home/node/src/utils/services/rabbitmq-consumer-service.js:42:51)

My code is as follows channel.ack(msg);

Fixed at my project but proposing the change at the library level by checking message object, thanks.

Using the same library version "name": "amqplib", "homepage": "http://amqp-node.github.io/amqplib/", "main": "./channel_api.js", "version": "0.10.3",

cressie176 commented 9 months ago

Hi @NevilDabre Thanks for the PR. What advantage does checking the input parameter and throwing a custom error have, over throwing the TypeError?