socket.io-client icon indicating copy to clipboard operation
socket.io-client copied to clipboard

Zuul tests fail when using multiple sockets

Open kevin-roark opened this issue 12 years ago • 5 comments

Currently mocha tests using zuul have to use the same global socket -- if each test uses a separate socket, only the first test passes and every other test fails, regardless of the test.

It is probably related to multiplexing and the single socket being closed. It is also probably socket.io level because engine.io browser tests use individual sockets and work fine.

kevin-roark avatar Feb 09 '14 17:02 kevin-roark

This fails:

  it('should connect to localhost', function(done) {
    var socket = io();
    socket.emit('hi');
    socket.on('hi', function(data){
      socket.close();
      done();
    });
  });

 it('should connect to localhost again', function(done) {
    var socket = io();
    socket.emit('hi');
    socket.on('hi', function(data){
      socket.close();
      done();
    });
  });

kevin-roark avatar Feb 09 '14 17:02 kevin-roark

But this passes:

var socket = io();
it('should connect to localhost', function(done) {
socket.emit('hi');
socket.on('hi', function(data){
done();
});
});

it('should connect to localhost again', function(done) {
var socket = io();
socket.emit('hi');
socket.on('hi', function(data){
done();
});
});

kevin-roark avatar Feb 09 '14 17:02 kevin-roark

@poohlty and I ran into this while writing tests.

The second time io() is called, the closed socket for '/' is returned. Inserting socket.open() before using it again almost works, but the original 'hi' handler is still bound, so it results in done() being called twice in the above example.

@guille: Was wondering if io()'s behavior could be to, if the socket exists but is not open, to reopen before returning it? Or is that too much of an exception?

JulianSlzr avatar Mar 06 '14 03:03 JulianSlzr

@kevin-roark can this be closed?

rase- avatar May 24 '14 19:05 rase-

This doesn't seem to be the case anymore.

rase- avatar Jan 12 '15 16:01 rase-