-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket errors don't get caught #1
Comments
I fixed this by patching the diff --git a/dist/index.js b/dist/index.js
index 608a23e75edd07db90aa393eec89a02394c4fdf6..5fd3730a8b6bc5391872d9dda12b89d30c68770d 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -66,8 +66,7 @@ export async function lookup(options) {
});
portal.once("error", (netError) => {
clearTimeout(timeoutFunc);
- reject();
- throw netError;
+ reject(netError);
});
let timeoutFunc = setTimeout(() => {
portal.destroy(); It seems like the first reject is throwing an error but the second reject will also throw an error which makes my outer try/catch not get the second error. Super strange |
Bug fixed in v1.1.3. The bug was caused by a slightly older build being published to NPM in the name of the update that fixed error catching, as such the single throw remained. Thanks for pointing this out. |
Please reopen, socket timeouts crash the application and cannot be caught in the consumer.
(I've patched the library myself to remove the |
@TheDevMinerTV You need to update to v1.1.3 |
Description
The Node.js socket errors don't get caught at the moment and there is no way to do so. Node.js will exit the process when a
EventEmitter
(such asnode:net.Socket
) emits an event called"error"
.Current behaviour
When the code receives a
Connection refused
, it will exit the process.Expected behaviour
It throws an error.
Proposal
Add a hook for the
"error"
socket event and on an error rethrow the error to the caller oflookup()
.The text was updated successfully, but these errors were encountered: