You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uncaught TypeError: response.setEncoding is not a function #961
I tried to install socket.io-client in a meteor app, it seems that browserify is responsible (see this issue), but I'm posting this here, because I believe other could have the same issue (and in case someone knows a better fix). Feel free to close the issue if you find it appropriate.
So my app crashes there, it's in the node-XMLHttpRequest (the repository doesn't accept issues), which is required by engine.io, which itself is required by socket.io-client.
So I decided to hack the browserify response object, like this:
import Response from 'meteor-node-stubs/node_modules/http-browserify/lib/response';
if(!Response.prototype.setEncoding) {
Response.prototype.setEncoding = function(encoding){
// do nothing
}
}
And so far it works.
Reacted by cyclopse87, Or Cohen, Comus Leong, Anton Savitskiy, Lenon vinhas, Stewart Celani, Samy Laumonier, Andres Olave and JaNe
In any file that gets loaded before you use the library.
Some main/index file would work. If you have an entry point for the code related to socket-io it's better. Or you could put it in a separate file that you'd name specifically so other understand it's a dirty fix, and then import it in a main/index file.
i have put this code in run(), it returns setEncoding = undefined, then i assign a function to it (according to your solution) ,it returns setEncoding = function, afterwords it returns setEncoding = undefined and gives error. i think the XMLHttpRequest.js load continuously that's why its re-change the type of setEncoding ?
Activity
shaharyar123 commentedon Sep 21, 2016
where to put this code ? any specific file ?
jstoeffler commentedon Sep 21, 2016
In any file that gets loaded before you use the library.
Some main/index file would work. If you have an entry point for the code related to socket-io it's better. Or you could put it in a separate file that you'd name specifically so other understand it's a dirty fix, and then import it in a main/index file.
shaharyar123 commentedon Sep 22, 2016
i have put this code in run(), it returns setEncoding = undefined, then i assign a function to it (according to your solution) ,it returns setEncoding = function, afterwords it returns setEncoding = undefined and gives error. i think the XMLHttpRequest.js load continuously that's why its re-change the type of setEncoding ?
jstoeffler commentedon Sep 23, 2016
That's weird. What's the
run()function you're talking about ?You probably want to do this outside a function, before your code is executed.
I don't understand why the
Responseprototype would change though.darrachequesne commentedon Jan 27, 2021
Closed due to inactivity, please reopen if needed.