-
Notifications
You must be signed in to change notification settings - Fork 353
Closed
Description
You want to:
- report a bug
- request a feature
Current behaviour
According to this pice of code:
https://github.com/socketio/engine.io-client/blob/master/lib/transports/websocket.js#L14-L22
NodeWebSocket
will be required ONLY if global variables self
and WebSocket
are not defined.
Steps to reproduce (if the current behaviour is a bug)
node.js:
global.self = {};
// - declaring global.self before requiring `websocket.js` will end up with timeout, because of mentioned block of code.
// It will try to set BrowserWebSocket = self.WebSocket || self.MozWebSocket; and fail.
// now both BrowserWebSocket and NodeWebSocket are undefined
const SocketIO = require('socket.io-client');
const socket = SocketIO('http://localhost', {
transports: ['websocket'],
timeout: 5000,
reconnection: false,
});
socket.on('connect', function () {
console.log('WS connected');
});
socket.on('connect_error', function (e) {
console.log('WS error', e);
});
Expected behaviour
NodeWebSocket should not be undefined
Setup
- OS: any
- nodejs
- engine.io version: current
Other information (e.g. stacktraces, related issues, suggestions how to fix)
Mentioned condition is not valid, there should be additional check if BrowserWebSocket
is set OR there should better nodejs environment detection (i think typeof self !== 'undefined
is not enough)
Metadata
Metadata
Assignees
Labels
No labels