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

Under node, io.transports contains duplicates #310

Closed
mixu opened this issue Sep 27, 2011 · 4 comments
Closed

Under node, io.transports contains duplicates #310

mixu opened this issue Sep 27, 2011 · 4 comments
Labels
bug Something isn't working

Comments

@mixu
Copy link
Contributor

mixu commented Sep 27, 2011

If you inspect io.transports, you will find that it contains ["websocket", "xhr-polling", "websocket", "xhr-polling"] under Node.

This is because under Node, io.transports contains the names of the supported transports, as added here:
https://github.com/LearnBoost/socket.io-client/blob/master/lib/io.js#L119

but then each transports appends it's name again when loaded, so you get duplicate transport names. I'd assume this is in part why I cannot get Node to emit connect_failed in my tests.

I'm not sure whether io.util.merge() works as intended for the transport array, if that array already contains items. Simple test case (for 0.8.4 via npm):

var obj = { transports: require('socket.io-client').transports };
console.log(obj); // { transports: ['websocket', 'xhr-polling', 'websocket', 'xhr-polling'] }
var result = require('socket.io-client').util.merge(obj, { transports: ['xhr-polling'] });
console.log(result); // { transports: ['xhr-polling', 'xhr-polling', 'websocket', 'xhr-polling'] }

For arrays like transports, it merges by replacing into the existing structure at the given position. util.merge is used to configure the sockets ( https://github.com/LearnBoost/socket.io-client/blob/master/lib/socket.js#L42 )

@3rd-Eden
Copy link
Contributor

Thanks for noticing does it cause you any big issues?

@mixu
Copy link
Contributor Author

mixu commented Sep 27, 2011

Not this specifically, but I would guess that this issue is related to the reconnect/connect_failed logic (e.g. Socket.redoTransports) not triggering the right events under Node: #311

That one is much more important, since it actually prevents me from verifying that my fallback code works..

@LionelMartin
Copy link

Sorry I didn't read that one carefully. Issue 322 is a duplicate of this one.
The result of this issue is quite important as the transport options set are often ignored.
Idea of fix available in issue 322

@rauchg rauchg closed this as completed Nov 25, 2014
@plumpNation
Copy link

plumpNation commented Aug 2, 2017

Duplicate of #322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants