-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Socket.io 4.2.x broken with Vite #4798
Comments
I have a similar problem. When using socket.io-client 4.2.x running vite in test/dev mode ( A different solution could als be to create a connection setting the transport option to 'websocket' first: That it skips the polling and it works with 4.2.x, but you don't have a fallback option than. |
Thank you @holygekko for our feedback. Changing the transports tor |
I could indeed reproduce the issue, it seems the So the // node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js
var require_XMLHttpRequest = __commonJS({
"node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js"(exports, module) {
var fs = (init_fs(), fs_exports);
var Url = (init_url(), url_exports);
var spawn = (init_child_process(), child_process_exports).spawn;
module.exports = XMLHttpRequest;
XMLHttpRequest.XMLHttpRequest = XMLHttpRequest;
function XMLHttpRequest(opts) {
"use strict";
opts = opts || {};
var self2 = this;
var http = (init_http(), http_exports);
var https = (init_https(), https_exports);
[...] Which explains:
What's weird is that the other fields in the |
As a workaround, it is possible to force the resolution in export default {
resolve: {
alias: {
"xmlhttprequest-ssl": "./node_modules/engine.io-client/lib/xmlhttprequest.js"
}
}
} I don't understand why the |
After a little digging in the Reproducible case: https://github.com/darrachequesne/vite-browser-issue Directly using |
I had problem with version 2.5.0. Nice to see there are some workarounds to the problem. In the meantime I managed to upgrade socket.io (together with the client) to the most recent version 4.5.1, and there everything seems to be working fine without any extra config. Just reporting. |
Describe the bug
Hello,
After an upgrade from socket.io 4.1.x to 4.2.x, it's not possible anymore to listen events.
Reproduction
I've created a project with three branches to reproduce the error:
With Webpack it works
https://github.com/shenron/issue-vue-vite-socket
With Vite it works only with socket.io 4.1.3
https://github.com/shenron/issue-vue-vite-socket/tree/vite-socket-4.1.3
With the last version of socket it's broken
https://github.com/shenron/issue-vue-vite-socket/tree/vite
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: