Description
Describe the bug
Socket.io client using sveltekit and firebase fails in production with the error: TypeError: Cannot read properties of undefined (reading 'bind')
. It works fine for my development server.
To Reproduce
Socket.IO client version: 4.8.1
Client
import { io } from "socket.io-client";
import { PUBLIC_SOCKET_HOST } from '$env/static/public';
try {
const socket = io(PUBLIC_SOCKET_HOST, {});
} catch(error) {
console.error('Error connecting to tempSocket',, error)
}
socket.on("connect", () => {
console.log(`connect ${socket.id}`);
});
socket.on("disconnect", () => {
console.log("disconnect");
});
Expected behavior
It should connect to the socket without failing
Platform:
- Firebase
- SvelteKit
Additional context
Here is the stack trace in the console:
Error connecting to tempSocket: TypeError: Cannot read properties of undefined (reading 'bind')
at j (index.CbhEcBzz.js:13:11191)
at new ae (index.CbhEcBzz.js:13:43136)
at ee (index.CbhEcBzz.js:13:47477)
at socket.CxTSg0fe.js:1:622
This seems to be the statement that fails in production:
function j(r, e) {
e.useNativeTimers ? (r.setTimeoutFn = tt.bind(w),
r.clearTimeoutFn = st.bind(w)) : (r.setTimeoutFn = w.setTimeout.bind(w),
r.clearTimeoutFn = w.clearTimeout.bind(w))
}