Skip to content
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.io-client 4.8.0 with Node native WebSocket 'Maximum call stack size exceeded' exception when closing the connection #5194

Open
vpmedia opened this issue Sep 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@vpmedia
Copy link

vpmedia commented Sep 22, 2024

Describe the bug
Using socket.io 4.8.0 server and socket.io-client 4.8.0 with native Node v21+ web socket transport I'm getting the following exception when the connection is closed between the client and the server.
The WebSocket client is running server side using the new transport WebSocket option added in v4.8.0.

process.on('uncaughtException') log:
(this is unexpected)

error: [Server] uncaughtException Maximum call stack size exceeded {"stack":"RangeError: Maximum call stack size exceeded\n    at emitInitScript (node:internal/async_hooks:495:24)\n    at process.nextTick (node:internal/process/task_queues:143:5)\n    at emitUncaughtException (node:internal/event_target:1090:11)\n    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:824:9)\n    at WebSocket.dispatchEvent (node:internal/event_target:751:26)\n    at fireEvent (node:internal/deps/undici/undici:11340:14)\n    at failWebsocketConnection (node:internal/deps/undici/undici:11421:9)\n    at closeWebSocketConnection (node:internal/deps/undici/undici:11692:9)\n    at WebSocket.close (node:internal/deps/undici/undici:12352:9)\n    at WS.doClose (file:///REDACTED/node_modules/engine.io-client/build/esm-debug/transports/websocket.js:83:21)"}

socket.on('connect_error') log:
(this is expected)

error: [Entity] onConnectError websocket error {"description":{},"stack":"Error: websocket error\n    at WS.onError (file:///REDACTED/node_modules/engine.io-client/build/esm-debug/transport.js:41:37)\n    at ws.onerror (file:///REDACTED/node_modules/engine.io-client/build/esm-debug/transports/websocket.js:51:39)\n    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:816:20)\n    at WebSocket.dispatchEvent (node:internal/event_target:751:26)\n    at fireEvent (node:internal/deps/undici/undici:11340:14)\n    at failWebsocketConnection (node:internal/deps/undici/undici:11421:9)\n    at Object.processResponse (node:internal/deps/undici/undici:11635:13)\n    at node:internal/deps/undici/undici:10425:23\n    at node:internal/process/task_queues:151:7\n    at AsyncResource.runInAsyncScope (node:async_hooks:211:14)","type":"TransportError"}
@vpmedia vpmedia added the to triage Waiting to be triaged by a member of the team label Sep 22, 2024
@vpmedia
Copy link
Author

vpmedia commented Sep 24, 2024

I've created a repository with a minimal example to reproduce the issue:
https://github.com/vpmedia/socketio-issue

my node version is v22.9.0
my system is macOS 15.0 / Apple M3 Max

@darrachequesne darrachequesne added bug Something isn't working and removed to triage Waiting to be triaged by a member of the team labels Oct 19, 2024
@darrachequesne
Copy link
Member

I could indeed reproduce the issue, thanks for the example 👍

This should be fixed by 4865f2e, included in engine.io-client@6.6.2. Could you please check?

@vpmedia
Copy link
Author

vpmedia commented Oct 25, 2024

I'm on leave at the moment but I'll test it after next week.
Thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants