Skip to content

unhandled exception if socket closes and 'error' is emitted #105

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

Merged
merged 1 commit into from
Oct 1, 2012

Conversation

jmatthewsr-ms
Copy link
Contributor

The following stack trace shows the exception thrown if the socket fails with ECONNABORTED.

Gist that reproduces the error: https://gist.github.com/3219285

I'm not 100% confident that this fix is in the right place. The uncaught exception appears to be from an unhandled 'error' event from eventemitter. This can occur if Socket._write (net.js:558:19) fails and Socket::_destroy() is called. If there is no callback specified to Socket::_destroy, then the 'error' event is emitted on next tick, which also bypasses any immediate try/catch blocks in Sender::frameAndSend().

events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: write ECONNABORTED
at errnoException (net.js:782:11)
at Socket._write (net.js:558:19)
at Socket.write (net.js:517:15)
at Sender.frameAndSend (c:\mydir\node-ws-exception\node_modules\ws\lib\Sender.js:146:22)
at Sender.close (c:\mydir\node-ws-exception\node_modules\ws\lib\Sender.js:43:8)
at WebSocket.close (c:\mydir\node-ws-exception\node_modules\ws\lib\WebSocket.js:89:18)
at Timer. (c:\mydir\node-ws-exception\client.js:35:20)
at Timer.exports.setInterval.timer.ontimeout (timers.js:234:14)

@einaros
Copy link
Contributor

einaros commented Aug 13, 2012

Hmm, I'll dig into this shortly. Sorry for the delay - vacation time and such :)

einaros added a commit that referenced this pull request Oct 1, 2012
unhandled exception if socket closes and 'error' is emitted
@einaros einaros merged commit 101788c into websockets:master Oct 1, 2012
@starlino
Copy link

starlino commented Sep 4, 2019

I have a similar error. Up to date on npm. Was this ever fixed and what is causing this ?? How can it be handled.

Error: connect ECONNABORTED 192.168.137.27:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
Emitted 'error' event at:
at ClientRequest.req.on (C:\PROJECTS\XYZ\node_modules\ws\lib\websocket.js:554:15)
at ClientRequest.emit (events.js:198:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants