conflict between box2dweb and socket.io versions 3 and 4 #4573
-
socket.io (versions 3 and 4) does not connect if box2dweb is in the global scope of the web page. Get the following error when calling the io method: manager.js:21 Uncaught TypeError: _this.reconnection is not a function https://github.com/hecht-software/box2dweb Below is a link showing the socket.io chat demo running normally and two links to pages with the error (see error in console). Also ran ESLint on the original and a closure-wrapped version of the box2dweb code. Rules and reports are shown below. The problem is very likely in the box2dweb code, an interaction in the global namespace, but don't see specifically what it is. Ideas? Thank you. --------- more info --------- my node app on heroku is running: socket.io chat demo running without error: Same chat demo with box2dweb included (see error in console): Same chat demo but with box2dweb included in a closure (see error in console): ESLint rules and reports: module.exports = { report on Box2D-original-wrapped.js 22:20 Error Shadowing of global property 'undefined'. no-shadow-restricted-names report on Box2D-original.js 18:5 Error Unexpected 'var' declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable. no-implicit-globals |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I see now that this is a new example of an old bug as discussed in issues 41, 43, and 44 of box2dweb. As discussed, there are several similar ways to eliminate the problem. I chose to change Object.prototype.defineProperty to Object.defineProperty in the first IF statement: Version 4 of socket.io is now in use: |
Beta Was this translation helpful? Give feedback.
I see now that this is a new example of an old bug as discussed in issues 41, 43, and 44 of box2dweb. As discussed, there are several similar ways to eliminate the problem.
I chose to change Object.prototype.defineProperty to Object.defineProperty in the first IF statement:
https://www.timetocode.org/Box2D.js.html
Version 4 of socket.io is now in use:
https://www.timetocode.org/