Skip to content

Uncaught Exception: TypeError: Cannot destructure property 'resolve' of '__classPrivateFieldGet(...).shift(...)' as it is undefined #2626

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

Closed
Alastair-Spencer opened this issue Oct 11, 2023 · 5 comments
Labels

Comments

@Alastair-Spencer
Copy link

Alastair-Spencer commented Oct 11, 2023

Description

Hello 👋🏻

Starting to add some resillency to our codebase and I was testing what would happen when the max clients have been reached.

I have ran config set maxclients 1 in my Redis server and started the project to see how this would be handled.

This fails with the following:

  • ConnectionTimeoutError
  • TypeError
  • SocketClosedUnexpectedlyError

Replication code

      client = createClient({
        url: 'redis://localhost:6379',
        socket: {
          connectTimeout: 1000,
        },
        pingInterval: 4 * 60 * 1000,
      });

      client.on('error', (err) => {
        console.log('Redis Error', err);
      });
      client.on('connect', () => console.log('Redis client is connecting'));
      client.on('reconnecting', () => console.log('Redis is reconnecting'));
      client.on('ready', () => console.log('Redis client is ready'));

Node.js Version

18.17.1

Redis Server Version

7.2.1

Node Redis Version

4.6.10

Platform

MacOS (Docker redis-stack)

Logs

ConnectionTimeoutError: Connection timeout
    at Socket.<anonymous> (/Users/alastair/projects/repo/node_modules/@redis/client/dist/lib/client/socket.js:177:124)
    at Object.onceWrapper (node:events:628:28)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at Socket._onTimeout (node:net:571:8)
    at listOnTimeout (node:internal/timers:569:17)
    at processTimers (node:internal/timers:512:7)

log: Redis is reconnecting
log: Redis client is connecting
log: Redis client is ready

Uncaught Exception: TypeError: Cannot destructure property 'resolve' of '__classPrivateFieldGet(...).shift(...)' as it is undefined.
    at Object.onReply (/Users/alastair/projects/repo/node_modules/@redis/client/dist/lib/client/commands-queue.js:62:25)
    at RESP2Decoder.write (/Users/alastair/projects/repo/node_modules/@redis/client/dist/lib/client/RESP2/decoder.js:119:26)
    at RedisCommandsQueue.onReplyChunk (/Users/alastair/projects/repo/node_modules/@redis/client/dist/lib/client/commands-queue.js:154:72)
    at RedisSocket.<anonymous> (/Users/alastair/projects/repo/node_modules/@redis/client/dist/lib/client/index.js:394:84)
    at RedisSocket.emit (node:events:514:28)
    at RedisSocket.emit (node:domain:489:12)
    at Socket.<anonymous> (/Users/alastair/projects/repo/node_modules/@redis/client/dist/lib/client/socket.js:201:42)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

SocketClosedUnexpectedlyError: Socket closed unexpectedly
    at Socket.<anonymous> (/Users/alastair/projects/repo/node_modules/@redis/client/dist/lib/client/socket.js:194:118)
    at Object.onceWrapper (node:events:629:26)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at TCP.<anonymous> (node:net:323:12)
@leibale
Copy link
Contributor

leibale commented Oct 11, 2023

Probably a duplicate of #2417

@leibale leibale closed this as completed Oct 17, 2023
@leibale leibale closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2023
@Alastair-Spencer
Copy link
Author

@leibale 👋🏻 Hope you're well and had a good Christmas / New Year!

It seems that #2632 has fixed the problem. It's not been noted in this change as a direct fix but it's been fixed by proxy.

@p-janik
Copy link

p-janik commented Apr 3, 2024

hey @leibale, it looks like we just hit into this problem recently:

TypeError: Cannot destructure property 'resolve' of '__classPrivateFieldGet(...).shift(...)' as it is undefined.
    at Object.onReply (/opt/app/node_modules/@redis/client/dist/lib/client/commands-queue.js:62:25)
    at RESP2Decoder.write (/opt/app/node_modules/@redis/client/dist/lib/client/RESP2/decoder.js:119:26)
    at RedisCommandsQueue.onReplyChunk (/opt/app/node_modules/@redis/client/dist/lib/client/commands-queue.js:154:72)
    at RedisSocket.<anonymous> (/opt/app/node_modules/@redis/client/dist/lib/client/index.js:410:84)
    at RedisSocket.emit (node:events:517:28)
    at RedisSocket.emit (node:domain:489:12)
    at Socket.<anonymous> (/opt/app/node_modules/@redis/client/dist/lib/client/socket.js:201:42)
    at Socket.emit (node:events:517:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
    at TCP.callbackTrampoline (node:internal/async_hooks:128:17)

We are already on the latest version of redis 4.6.13. We use node v18.20.0.

@mattfiocca
Copy link

Same here, node-redis 4.7.0, node 18.14.0.

But in our case we have a client-facing gRPC service, that when a stream is initiated we perform a pSubscribe for that stream call. If the gRPC client<->server socket crashes for whatever reason (like a proto serialization error), and we don't call pUnsubscribe or disconnect() with redis, we get this error almost exactly 60 seconds after the gRPC client went away. I'm still trying to figure out where exactly this is being thrown in our own code, so I can tell if it's an issue on our end or not.

I'm thinking it might have something to do with garbage collection, since the redis connection and client object live inside the gRPC call initiator / scope. When node kills the gRPC client the redis object goes with it, without us having a chance to call unsubscribe or disconnect.

TypeError: Cannot destructure property 'resolve' of '__classPrivateFieldGet(...).shift(...)' as it is undefined.
    at Object.onReply (/usr/src/app/node_modules/@redis/client/dist/lib/client/commands-queue.js:62:25)
    at RESP2Decoder.write (/usr/src/app/node_modules/@redis/client/dist/lib/client/RESP2/decoder.js:119:26)
    at RedisCommandsQueue.onReplyChunk (/usr/src/app/node_modules/@redis/client/dist/lib/client/commands-queue.js:154:72)
    at RedisSocket.<anonymous> (/usr/src/app/node_modules/@redis/client/dist/lib/client/index.js:420:84)
    at RedisSocket.emit (node:events:513:28)
    at RedisSocket.emit (node:domain:489:12)
    at Socket.<anonymous> (/usr/src/app/node_modules/@redis/client/dist/lib/client/socket.js:201:42)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)

@DoobleD
Copy link

DoobleD commented Nov 10, 2024

Hi, same here, even with #2653. For us it happens after failovers when we use CLIENT KILL to force clients to reconnect to the new master.

TypeError: Cannot destructure property 'resolve' of '__classPrivateFieldGet(...).shift(...)' as it is undefined.
    at Object.onReply (/opt/app/node_modules/@redis/client/dist/lib/client/commands-queue.js:62:25)
    at RESP2Decoder.write (/opt/app/node_modules/@redis/client/dist/lib/client/RESP2/decoder.js:119:26)
    at RedisCommandsQueue.onReplyChunk (/opt/app/node_modules/@redis/client/dist/lib/client/commands-queue.js:154:72)
    at RedisSocket.<anonymous> (/opt/app/node_modules/@redis/client/dist/lib/client/index.js:411:84)
    at RedisSocket.emit (node:events:519:28)
    at Socket.<anonymous> (/opt/app/node_modules/@redis/client/dist/lib/client/socket.js:202:42)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)

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

No branches or pull requests

5 participants