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

Memorystore Redis Code Sample - Out of Sync with Node.js Redis 4.X Upgrade - Leads to ClientClosedError #3600

Open
rohank-gcp opened this issue Jan 8, 2024 · 0 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@rohank-gcp
Copy link

rohank-gcp commented Jan 8, 2024

In which file did you encounter the issue?

https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/main/memorystore/redis/server.js

Did you change the file? If so, how?

Not yet. But the recommendation is to replace below line -

const client = redis.createClient(REDISPORT, REDISHOST);

with

const client = redis.createClient({socket: {host: REDISHOST, port: REDISPORT}});
client.connect();

Describe the issue

  • The Github sample tutorial package.json was updated for Node redis package dependency from 3.X to 4.X recently.
  • Based on Node Redis package v3 to v4 migration guide, the new client no longer supports auto-connect functionality.
  • The main server.js code is not updated and still relies on auto-connect feature which got disabled as described earlier.
  • I tried running this code sample locally and get ClientClosedError error consistently -
    /home/test-user/nodejs-samples-latest/memorystore/redis/node_modules/@redis/client/dist/lib/client/index.js:511
          return Promise.reject(new errors_1.ClientClosedError());
                                ^
    ClientClosedError: The client is closed
      at Commander._RedisClient_sendCommand (/home/test-user/nodejs-samples- 
    latest/memorystore/redis/node_modules/@redis/client/dist/lib/client/index.js:511:31)
      at Commander.commandsExecutor (/home/test-user/nodejs-samples- 
    latest/memorystore/redis/node_modules/@redis/client/dist/lib/client/index.js:190:154)
      at Commander.BaseClass.<computed> [as incr] (/home/test-user/nodejs-samples- 
    latest/memorystore/redis/node_modules/@redis/client/dist/lib/commander.js:8:29)
      at Server.<anonymous> (/home/test-user/nodejs-samples-latest/memorystore/redis/server.js:30:12)
      at Server.emit (node:events:513:28)
      at parserOnIncoming (node:_http_server:998:12)
      at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
    
  • Please update the code sample to fix this anomaly.

Thanks!

@rohank-gcp rohank-gcp added priority: p2 Moderately-important priority. Fix may not be included in next release. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 8, 2024
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. samples Issues that are directly related to samples. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant