-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(client): Avoids infinite promise-chaining when socket's creation fails #2295
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
Conversation
@JonasFaure nice one! sorry for the long delay, I was on vacation... I'll release a version with this fix next week :) |
Codecov ReportBase: 95.85% // Head: 95.85% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2295 +/- ##
=======================================
Coverage 95.85% 95.85%
=======================================
Files 433 433
Lines 4001 4004 +3
Branches 451 451
=======================================
+ Hits 3835 3838 +3
Misses 102 102
Partials 64 64
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
…fails (redis#2295) * fix(client): timeout issues during tests * fix(client): avoiding infinite Promise chaining while socket creation fails * fix(client): Added missing semicolons * clean test Co-authored-by: leibale <[email protected]>
In [email protected] and earlier versions of redis v4, client.disconnect() will throw if the connect failed. That broke the "with empty string for client URL, ..." test case, at least on macOS: npm run test:docker:run RUN_REDIS_TESTS=1 npm t I cannot explain why this is not failing in CI. Perhaps something platform specific? This is related to socket handling in the redis client. I believe the relevant change in node-redis was: redis/node-redis#2295 which was part of `@redis/[email protected]` which was included in `[email protected]`.
…#2914) In [email protected] and earlier versions of redis v4, client.disconnect() will throw if the connect failed. That broke the "with empty string for client URL, ..." test case, at least on macOS: npm run test:docker:run RUN_REDIS_TESTS=1 npm t I cannot explain why this is not failing in CI. Perhaps something platform specific? This is related to socket handling in the redis client. I believe the relevant change in node-redis was: redis/node-redis#2295 which was part of `@redis/[email protected]` which was included in `[email protected]`.
Description
This change prevents a memory leak when a Redis client tries to connect to an unavailable host. This is achieve by switching from a recursive to an iterative approach.
When a Redis instance fails, our clients slowly build up memory until they get killed.
#2134
First, I had to slightly change the tests' implementation to work around timeout issues when running the tests, ie : specifying a timeout using the connectTimeout argument & giving up mocking time by specifying a very small retry delay. This commit should preferably be reverted if someone who manages to run tests locally can validate my implementation with the previous implementation for those tests 🤷
Second, I swapped the recursive call to
connect
for a do{}while loop and leverage the#this.isReady
property as the exit condition.Checklist
npm test
pass with this change (including linting)?