Skip to content

Socket.use error drops server #2771

@serhiisol

Description

@serhiisol

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

Result

Socket cannot use event error as fallback =), if I'll use socket.error instead, system works as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions