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

Missing error handler on socket. when using node.js v0.12 #2047

Closed
smartmouse opened this issue Mar 10, 2015 · 7 comments
Closed

Missing error handler on socket. when using node.js v0.12 #2047

smartmouse opened this issue Mar 10, 2015 · 7 comments
Labels
enhancement New feature or request
Milestone

Comments

@smartmouse
Copy link

:˜/test/socket.io$ npm test

socket.io@1.3.2 test /home/test/socket.io
mocha --reporter dot --slow 200ms --bail

child_process: customFds option is deprecated, use stdio instead.

․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
․․․․․․․․․․․․․․․․․․․․․․․․․Note: warning expected and normal in test.
Missing error handler on socket.
Error: Illegal attachments
at decodeString (/home/test/socket.io/node_modules/socket.io-parser/index.js:290:13)
at Decoder.add (/home/test/socket.io/node_modules/socket.io-parser/index.js:238:14)
at Client.ondata (/home/test/socket.io/lib/client.js:176:18)
at Socket.emit (events.js:107:17)
at Socket.onPacket (/home/test/socket.io/node_modules/engine.io/lib/socket.js:99:14)
at WebSocket.emit (events.js:129:20)
at WebSocket.Transport.onPacket (/home/test/socket.io/node_modules/engine.io/lib/transport.js:91:8)
at WebSocket.Transport.onData (/home/socket.io/node_modules/engine.io/lib/transport.js:102:8)
at WebSocket.onData (/home/socket.io/node_modules/engine.io/lib/transports/websocket.js:75:30)
at WebSocket.emit (events.js:110:17)
at Receiver.ontext (/home/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocket.js:798:10)
at /home/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.js:473:18
at /home/test/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.js:357:7
at /home/test/socket.io/node_modules/engine.io/node_modules/ws/lib/PerMessageDeflate.js:217:5
at afterWrite (_stream_writable.js:361:3)
at onwrite (_stream_writable.js:352:7)
at WritableState.onwrite (_stream_writable.js:105:5)

@smartmouse
Copy link
Author

still the same issue --for socket.io@1.3.6 node version is 0.12.7

socket.io@1.3.6 test /home/nodebot/test/socket.io
mocha --reporter dot --slow 200ms --bail

child_process: customFds option is deprecated, use stdio instead.

․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
․․․․․․․․․․․․․․․․․․․․․․․․․․․․․Note: warning expected and normal in test.
Missing error handler on socket.
Error: Illegal attachments
at decodeString (/home/nodebot/test/socket.io/node_modules/socket.io-parser/index.js:290:13)
at Decoder.add (/home/nodebot/test/socket.io/node_modules/socket.io-parser/index.js:238:14)
at Client.ondata (/home/nodebot/test/socket.io/lib/client.js:175:18)
at Socket.emit (events.js:107:17)
at Socket.onPacket (/home/nodebot/test/socket.io/node_modules/engine.io/lib/socket.js:101:14)
at WebSocket.emit (events.js:107:17)
at WebSocket.Transport.onPacket (/home/nodebot/test/socket.io/node_modules/engine.io/lib/transport.js:93:8)
at WebSocket.Transport.onData (/home/nodebot/test/socket.io/node_modules/engine.io/lib/transport.js:104:8)
at WebSocket.onData (/home/nodebot/test/socket.io/node_modules/engine.io/lib/transports/websocket.js:75:30)
at WebSocket.emit (events.js:110:17)
at Receiver.ontext (/home/nodebot/test/socket.io/node_modules/engine.io/node_modules/ws/lib/WebSocket.js:797:10)
at /home/nodebot/test/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.js:473:18
at /home/nodebot/test/socket.io/node_modules/engine.io/node_modules/ws/lib/Receiver.js:357:7
at /home/nodebot/test/socket.io/node_modules/engine.io/node_modules/ws/lib/PerMessageDeflate.js:217:5
at afterWrite (_stream_writable.js:361:3)
at onwrite (_stream_writable.js:352:7)
at WritableState.onwrite (_stream_writable.js:105:5)
at afterTransform (_stream_transform.js:99:5)
at TransformState.afterTransform (_stream_transform.js:74:12)
at Zlib.callback (zlib.js:611:5)
․․․․․․․․․․․․․․․․․․․

107 passing (14s)

@darrachequesne
Copy link
Member

That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).

@Novivy
Copy link

Novivy commented Apr 25, 2022

This is still happening on node v12.18.2, what could cause this? bad payload from client?

@darrachequesne
Copy link
Member

@Novivy yes, this could indeed be caused by a bad payload from the client:

socket.io/lib/client.ts

Lines 296 to 301 in 9b43c91

private onerror(err): void {
for (const socket of this.sockets.values()) {
socket._onerror(err);
}
this.conn.close();
}

@Novivy
Copy link

Novivy commented May 3, 2022

@Novivy yes, this could indeed be caused by a bad payload from the client:

socket.io/lib/client.ts

Lines 296 to 301 in 9b43c91

private onerror(err): void {
for (const socket of this.sockets.values()) {
socket._onerror(err);
}
this.conn.close();
}

any suggestions to PR this?

@darrachequesne
Copy link
Member

For now, I think you can add an empty error handler:

socket.on("error", () => {});

We will remove this in the next major version, as this does not provide much value (the socket is disconnect in any case).

@darrachequesne darrachequesne added the enhancement New feature or request label May 12, 2022
@darrachequesne darrachequesne added this to the 5.0.0 milestone May 12, 2022
darrachequesne added a commit that referenced this issue May 24, 2023
We should reduce the scope of the "event" error in the next major
version, as it is overloaded today:

- it can be sent by the client (`socket.emit("error")`, which is a perfectly valid event name)
- it can be emitted when the connection encounters an error (an invalid packet for example)
- it can be emitted when a packet is rejected in a middleware (`socket.use()`)

Related: #2047
@darrachequesne
Copy link
Member

For future readers:

The warning was silenced in 15af22f, included in version 4.6.2.

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

No branches or pull requests

4 participants
@smartmouse @darrachequesne @Novivy and others