Skip to content
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

TypeError with @socket.io/redis-adapter on Node.js v18.15.0 #534

Open
govind-amt opened this issue Mar 20, 2024 · 5 comments
Open

TypeError with @socket.io/redis-adapter on Node.js v18.15.0 #534

govind-amt opened this issue Mar 20, 2024 · 5 comments

Comments

@govind-amt
Copy link

govind-amt commented Mar 20, 2024

I'm encountering an unexpected error when utilizing the socket.io/redis-adapter in my application. Below are the error logs for your reference:

Environment:

  • Node.js Version: 18.15.0
  • Redis Instance Version: redis:7.0.11-alpine
  • Docker container

Dependencies:

  • "redis": "4"
  • "@socket.io/redis-adapter": "^8.2.1"
  • "socket.io": "4.5.1"
  • "socket.io-client": "4.5.1"

Error Log:

Node.js v18.15.0
/app/node_modules/@[socket.io/redis-adapter/dist/sharded-adapter.js:27](http://socket.io/redis-adapter/dist/sharded-adapter.js:27)
class ShardedRedisAdapter extends socket_io_adapter_1.ClusterAdapter {
                                                      ^

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/app/node_modules/@[socket.io/redis-adapter/dist/sharded-adapter.js:27:55](http://socket.io/redis-adapter/dist/sharded-adapter.js:27:55))
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/app/node_modules/@[socket.io/redis-adapter/dist/index.js:704:25](http://socket.io/redis-adapter/dist/index.js:704:25))
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/app/main.js:12473:18)
    at __webpack_require__ (/app/main.js:12549:42)

Node.js v18.15.0

I would appreciate any assistance to resolve this issue.

@nwalters512
Copy link

It looks like the following change silently changed the minimum version of socket.io-adapter that's required:

7fb6b90

Some package managers will automatically install required peer dependencies. Mine did not; I ran yarn add socket.io-adapter && yarn dedupe && yarn remove socket.io-adapter, and now things work correctly.

@darrachequesne
Copy link
Member

@nwalters512 arf, I did not test with yarn, sorry for that.

@govind-amt which version of socket.io-parser package (imported by both socket.io and @socket.io/redis-adapter) is installed?

@vvtri
Copy link

vvtri commented Mar 26, 2024

@nwalters512 arf, I did not test with yarn, sorry for that.

@govind-amt which version of socket.io-parser package (imported by both socket.io and @socket.io/redis-adapter) is installed?

I get same error, I used socket.io-adapter@2.5.2 and @socket.io/redis-adapter@8.3.0

@darrachequesne
Copy link
Member

@vvtri that's weird, you should have socket.io-adapter@2.5.4. Could you please try running npm update socket.io-adapter to see if it fixes your issue?

@xtrinch
Copy link

xtrinch commented Apr 3, 2024

Yeah same issue here, it installs socket.io-adapter@2.5.2. Even pinning it to 2.5.4 in package.json doesn't help
Setting

  "resolutions": {
    "socket.io-adapter": "2.5.4"
  }

in package.json works and fixes the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants