How are errors actually supposed to be handled? #3135
-
|
There's this example in the readme[1]: additionaly the document says
My question is: what should the listener actually do? Surely I shouldn't just ignore the errors (logging doesn't count as doing anything in my books)? What is the right way to handle this in production code? What kinds of errors can we even get there? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The error event listener requirement is a Node.js EventEmitter thing - without it, errors crash your process. The client already handles reconnection automatically, so for most applications, logging + optional monitoring integration is actually a reasonable approach. The errors you see there are network-level issues that the client is already working to recover from. If you need stricter behavior, use |
Beta Was this translation helpful? Give feedback.
The error event listener requirement is a Node.js EventEmitter thing - without it, errors crash your process. The client already handles reconnection automatically, so for most applications, logging + optional monitoring integration is actually a reasonable approach. The errors you see there are network-level issues that the client is already working to recover from.
If you need stricter behavior, use
reconnectStrategyto control when to give up