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

NodeWebSocket declaration issue (nodejs project) #609

Closed
1 of 2 tasks
szymonlesisz opened this issue Apr 25, 2019 · 0 comments
Closed
1 of 2 tasks

NodeWebSocket declaration issue (nodejs project) #609

szymonlesisz opened this issue Apr 25, 2019 · 0 comments

Comments

@szymonlesisz
Copy link
Contributor

szymonlesisz commented Apr 25, 2019

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)

enderson-pan pushed a commit to holytiny/feathersjs-wxmp-socket.io-client that referenced this issue Nov 1, 2019
NodeWebSocket was be required ONLY if global variables self and WebSocket were not defined.

Closes socketio/engine.io-client#609
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant