You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the only way to detect if this library throws an error on connection (as opposed to something else) is to check for the string err.message.startsWith('WebSocket closed with reason:').
For example this error is thrown on an unsuccessful await wsp.open() call:
RWS> addListeners
RWS> error event connect ECONNREFUSED ::1:3456
Error: WebSocket closed with reason: (1000).
at WebSocketAsPromised._handleClose (/Users/user/Projects/web/node_modules/.pnpm/websocket-as-promised@2.0.1/node_modules/websocket-as-promised/src/index.js:408:19)
at listener (/Users/user/Projects/web/node_modules/.pnpm/websocket-as-promised@2.0.1/node_modules/websocket-as-promised/src/index.js:340:64)
at ReconnectingWebSocket._callEventListener (/Users/user/Projects/web/node_modules/.pnpm/reconnecting-websocket@4.4.0/node_modules/reconnecting-websocket/dist/reconnecting-websocket-cjs.js:557:13)
at /Users/user/Projects/web/node_modules/.pnpm/reconnecting-websocket@4.4.0/node_modules/reconnecting-websocket/dist/reconnecting-websocket-cjs.js:197:79
at Array.forEach (<anonymous>)
at ReconnectingWebSocket._handleClose (/Users/user/Projects/web/node_modules/.pnpm/reconnecting-websocket@4.4.0/node_modules/reconnecting-websocket/dist/reconnecting-websocket-cjs.js:197:36)
at ReconnectingWebSocket._disconnect (/Users/user/Projects/web/node_modules/.pnpm/reconnecting-websocket@4.4.0/node_modules/reconnecting-websocket/dist/reconnecting-websocket-cjs.js:540:18)
at ReconnectingWebSocket._handleError (/Users/user/Projects/web/node_modules/.pnpm/reconnecting-websocket@4.4.0/node_modules/reconnecting-websocket/dist/reconnecting-websocket-cjs.js:180:19)
at callListener (/Users/user/Projects/web/node_modules/.pnpm/ws@8.14.2_nn4cfacdngcg7bs47xs3zpla7u/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onError (/Users/user/Projects/web/node_modules/.pnpm/ws@8.14.2_nn4cfacdngcg7bs47xs3zpla7u/node_modules/ws/lib/event-target.js:230:9)
at WebSocket.emit (node:events:513:28)
at emitErrorAndClose (/Users/user/Projects/web/node_modules/.pnpm/ws@8.14.2_nn4cfacdngcg7bs47xs3zpla7u/node_modules/ws/lib/websocket.js:1016:13)
at ClientRequest.<anonymous> (/Users/user/Projects/web/node_modules/.pnpm/ws@8.14.2_nn4cfacdngcg7bs47xs3zpla7u/node_modules/ws/lib/websocket.js:864:5)
at ClientRequest.emit (node:events:513:28)
at Socket.socketErrorListener (node:_http_client:502:9)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Having access to the raw error would be useful for error handling purposes (e.g. being able to see err.code is ECONNREFUSED.
Additionally, the err.reason property can be empty, and as you can see from the above example it has extra whitespace added to the error string (which isn't dev-friendly). This will require a rewrite to _handleClose and _handleError handlers most likely (?)
Right now the only way to detect if this library throws an error on connection (as opposed to something else) is to check for the string
err.message.startsWith('WebSocket closed with reason:')
.For example this error is thrown on an unsuccessful
await wsp.open()
call:Having access to the raw error would be useful for error handling purposes (e.g. being able to see
err.code
isECONNREFUSED
.Additionally, the
err.reason
property can be empty, and as you can see from the above example it has extra whitespace added to the error string (which isn't dev-friendly). This will require a rewrite to_handleClose
and_handleError
handlers most likely (?)Reference:
websocket-as-promised/src/index.js
Line 407 in bc60644
The text was updated successfully, but these errors were encountered: