socket.io: v4.3.0 breaks testem
Describe the bug As of the v4.3.0 release, testem (and therefore all CI runs which use it, so this will shortly be hitting the whole Ember.js community and any others as they upgrade or for runs which check against “drifted dependencies”) is failing with the following error:
io.connect is not a function
Inspecting io shows that it is in fact the lookup function (dist).
To Reproduce
Unfortunately, this is a bit involved, and I don’t have a good minimal reproduction yet. I will add one later. For now, I will link directly to the relevant bits of testem’s source.
Socket.IO server version: 4.3.0
Server
- importing
socket.ioas `const socketIO = require(‘socket.io’); - using the imported value as a function
Socket.IO client version: x.y.z
Client
Expected behavior
Given 4.3.0 was a patch release, testem’s previous usage should continue to work without issue.
Platform:
- Device: Mac or Linux
- OS: Ubuntu latest, macOS 11.6, etc.
Additional context
I strongly suspect (but haven’t yet been able to prove) that this is related to either the engine.io bump, serving ESM, or the intersection of the two.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 16 (3 by maintainers)
Commits related to this issue
- feat: provide an ESM build with and without debug See also: https://github.com/socketio/engine.io-client/commit/00d7e7d7ee85b4cfa6f9f547203cc692083ac61c Related: - https://github.com/socketio/socke... — committed to socketio/socket.io-client by darrachequesne 3 years ago
- feat: serve ESM bundle Related: - https://github.com/socketio/socket.io-client/commit/0661564dc2005b95843ddb65621b7e89af702bc0 - https://github.com/socketio/socket.io-client/issues/1198 — committed to socketio/socket.io by darrachequesne 3 years ago
- Fix re-export of `io` module The previous (CJS module) export semantics were of a *namespace*-style export, while the semantics introduced in c76d367 are of a single value exported as the default v... — committed to chriskrycho/socket.io-client by chriskrycho 3 years ago
- chore(deps): re-roll yarn.lock and pin socket.io to 4.2.0 (#568) Version 4.3.0 of socket.io breaks testem connection when running tests headless. Reference socketio/socket.io/issues/4121 — committed to adopted-ember-addons/ember-file-upload by gilest 3 years ago
- Pin socket.io to fix CI See https://github.com/socketio/socket.io/issues/4121 — committed to simonihmig/ember-stargate by simonihmig 3 years ago
- chore: temp pin `socket.io` See https://github.com/socketio/socket.io/issues/4121 for more info. — committed to chrislopresto/ember-freestyle by bertdeblock 3 years ago
- chore: temp pin `socket.io` See https://github.com/socketio/socket.io/issues/4121 for more info. — committed to chrislopresto/ember-freestyle by bertdeblock 3 years ago
- fix: restore the namespace export This restores the previous behavior, where the "io" object available in the browser could be used as a function (`io()`) or as a namespace (`io.connect()`). The bre... — committed to socketio/socket.io-client by chriskrycho 3 years ago
- fix: restore the namespace export This restores the previous behavior, where the "io" object available in the browser could be used as a function (`io()`) or as a namespace (`io.connect()`). The bre... — committed to sunrise30/socket.io-client by sunrise30 3 years ago
@chriskrycho done! https://github.com/socketio/socket.io/releases/tag/4.3.1
This should be fixed by https://github.com/socketio/socket.io-client/commit/8737d0ae6fb362455015e6dd435010c36d023663, which was included in ̀socket.io-client@4.3.1.
Aside: JavaScript is such shenanigans. The fact that an export can be both a function and a namespace is just… 🙃😩🤪🥴
Shouldn’t. The CI breakage is just from the Ember CI defaults of including a run which lets all dependencies resolve to their latest legal version (using
--no-lockfile), precisely so we catch issues like this early. Once the release is out, all of the CI jobs should start passing again.If you’re seeing the CI builds fail from this issue (as I have on
ember-modifier), it’s almost certainly because of a cache issue which is causing other runs to inherit the bad version even though per the lock file they shouldn’t. That should also get fixed (via the same bad cache behavior!) oncesocket.iocuts 4.3.1. I’m going to poke at the CI config a bit on Monday and see if there’s something we need to tweak for the GH Actions defaults to make sure that part doesn’t become a problem again in the future.@chriskrycho @darrachequesne I maybe missing something, as far as I can see we need a new release of
socket.iobecause client is bundled withsocket.io, in theclient-distfolder.E.g. Testem.js does not depend on
socket.io-client, it only hassocket.ioin it’sdependencies