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).

Screen Shot 2021-10-14 at 16 31 05

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.io as `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

Most upvoted comments

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!) once socket.io cuts 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.io because client is bundled with socket.io, in the client-dist folder.

E.g. Testem.js does not depend on socket.io-client, it only has socket.io in it’s dependencies