-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Closed
Description
You want to:
- report a bug
Current behaviour
Socket.use drops server in case if we'll pass error into the next function
Steps to reproduce (if the current behaviour is a bug)
Next snippet reproduces error easily:
let io = require('socket.io')(3000);
io.on('connection', (socket) => {
socket.use((packet, next) => {
next(new Error('Failed error, which drops server'));
});
socket.on('message', (message) => {
console.log(message);
});
});
Expected behaviour
Should send error packet back to the client and definitely shouldn't drop server
Setup
- OS: macOS Sierra 10.12.1
- browser: Chrome Version 54.0.2840.98 (64-bit)
- socket.io version: 1.7.1
Other information (e.g. stacktraces, related issues, suggestions how to fix)
events.js:165
throw err;
^
Error: Uncaught, unspecified "error" event. (undefined)
at Socket.emit (events.js:163:17)
at Socket.emit (/Users/serhiysolonko/Google Drive/Projects/Code/@decorators/playground/socket/node_modules/socket.io/lib/socket.js:141:10)
at /Users/serhiysolonko/Google Drive/Projects/Code/@decorators/playground/socket/node_modules/socket.io/lib/socket.js:501:21
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Possible place to debug
- https://nodejs.org/api/events.html#events_error_events
- https://github.com/socketio/socket.io/blob/master/lib/socket.js#L495
Result
Socket cannot use event error
as fallback =), if I'll use socket.error
instead, system works as expected
Metadata
Metadata
Assignees
Labels
No labels