Feature Request - timeout for publish and sendToQueue
I've noticed that if the client cannot connect, calling to sendToQueue from the channel wrapper creates a promise that never resolves or rejects.
This is an acceptable behavior in a "callbacks-api", but not in a "promises-api": calling await channel.sendToQueue(...) is dangerous for memory...
I wish this feature would exist in the original amqplib package, but their github page seems to be overloaded with issues and I don't think they will add such feature soon.
p-timeout could be helpful here. Is it possible to force "canceling" of the message being sent after sendToQueue was called (i.e. when the timeout is reached)? I guess I could call "disconnect" and destroy the whole connection instance.
Thanks!
A better approach is to create a timer that calls channel.close(). This call will make the pending sendToQueue promise reject with Error: Channel closed.
We just discovered a different use case for a timeout feature: When used in conjunction with an HTTP-API, we would like to have the HTTP request be responded with 2XX once rabbitmq confirms a message and with 503 if rabbitmq did not confirm for X seconds. Having a timeout for publish / sendToQueue, or having a possibility to cancel is required for such a usecase too. Would you accept a PR for this?
@designtesbrot i have the same requirement