getting the following exception randomly in Nodejs application, which terminates it
events.js:291
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:208:20)
at TLSWrap.callbackTrampoline (internal/async_hooks.js:126:14)
Emitted 'error' event on Client instance at:
at TLSSocket.onSocketError (/usr/src/app/node_modules/ldapjs/lib/client/client.js:966:12)
at TLSSocket.emit (events.js:314:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall: 'read'
Can you please suggest what to check? I'm using ldapjs-promise wrapping around your library, but I see that it's thrown out from the middle of your code. Interesting thing that I have the whole client lifecycle managed inside try {} catch block
It looks like a connection reset error. So the server hung up on you. You have to listen for the error event on the client.
Thank you @jsumners , gonna try to add the handler to see if there is any change.
@phi1ipp You can add a global listener, to handle such errors in your application, so that your application won't terminate.
// Global Error handlers
process.on('uncaughtException', function(err) {
console.error('Uncaught Exception: ', err);
});
process.on('unhandledRejection', (reason, p) => {
console.error('Unhandled Rejection: ', p, 'Reason: ', reason);
});
Edit: As also mentioned by @jsumners uncaughtException and unhandledRejection should be used with extreme caution. I attach the docs with the relevant Warning
@SkourasKonst you should not let your application continue to run if an uncaughtException or unhandledRejection is encountered. You are very likely to encounter memory leaks and other errors if you do.
Closing this as I believe it has been answered. Feel free to reopen if you are still having issues.
Most helpful comment
@SkourasKonst you should not let your application continue to run if an
uncaughtExceptionorunhandledRejectionis encountered. You are very likely to encounter memory leaks and other errors if you do.Closing this as I believe it has been answered. Feel free to reopen if you are still having issues.