Skip to content

Conversation

phpbg
Copy link
Contributor

@phpbg phpbg commented Sep 2, 2022

Description

Document network errors handling and reconnect strategy


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

@leibale
Copy link
Contributor

leibale commented Sep 2, 2022

I think it'll fit better in the client-configuration.md file

@phpbg
Copy link
Contributor Author

phpbg commented Sep 2, 2022

i didn't even notice there was more doc... lol

I guess it isn't relevant anymore?

@leibale
Copy link
Contributor

leibale commented Sep 12, 2022

@phpbg I think that we should merge your changes into that doc somehow.. :)

@phpbg phpbg marked this pull request as draft September 14, 2022 19:59
@phpbg
Copy link
Contributor Author

phpbg commented Sep 14, 2022

ok, i'll move them to client-configuration.md

@phpbg phpbg marked this pull request as ready for review September 16, 2022 15:04
@phpbg
Copy link
Contributor Author

phpbg commented Sep 16, 2022

@leibale It should be in better shape now ;-)

Copy link
Contributor

@chayim chayim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change to the text, approving.

@phpbg
Copy link
Contributor Author

phpbg commented Oct 21, 2022

@leibale @chayim I let you merge as I don't have write access

You can implement a custom reconnect strategy as a function:
When a network error occurs the client will automatically try to reconnect, following a default linear strategy (the more attempts, the more waiting before trying to reconnect).

This strategy can be overriden by providing a `socket.reconnectStrategy` option during client's creation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. overridden
  2. during the client's creation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

import { createClient } from 'redis';

const client = createClient({
url: 'redis://alice:foobared@awesome.redis.server:6380',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to show url in this example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@leibale
Copy link
Contributor

leibale commented Oct 21, 2022

@phpbg sorry for the long dealy, I was on vacation..

@codecov-commenter
Copy link

codecov-commenter commented Jan 18, 2023

Codecov Report

Base: 95.85% // Head: 95.85% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (42910c8) compared to base (5dd7d31).
Patch coverage: 94.85% of modified lines in pull request are covered.

❗ Current head 42910c8 differs from pull request most recent head e90eb9a. Consider uploading reports for the commit e90eb9a to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2250    +/-   ##
========================================
  Coverage   95.85%   95.85%            
========================================
  Files         433      451    +18     
  Lines        4001     4247   +246     
  Branches      451      475    +24     
========================================
+ Hits         3835     4071   +236     
- Misses        102      106     +4     
- Partials       64       70     +6     
Impacted Files Coverage Δ
packages/search/lib/commands/SEARCH.ts 82.60% <71.42%> (-9.70%) ⬇️
packages/client/lib/client/socket.ts 77.96% <81.08%> (-2.04%) ⬇️
packages/client/lib/client/index.ts 92.00% <94.73%> (+0.58%) ⬆️
packages/graph/lib/graph.ts 96.29% <96.29%> (ø)
packages/bloom/lib/commands/bloom/CARD.ts 100.00% <100.00%> (ø)
packages/bloom/lib/commands/bloom/index.ts 100.00% <100.00%> (ø)
packages/bloom/lib/commands/t-digest/ADD.ts 100.00% <100.00%> (ø)
packages/bloom/lib/commands/t-digest/BYRANK.ts 100.00% <100.00%> (ø)
packages/bloom/lib/commands/t-digest/BYREVRANK.ts 100.00% <100.00%> (ø)
packages/bloom/lib/commands/t-digest/CDF.ts 100.00% <100.00%> (ø)
... and 25 more

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@leibale
Copy link
Contributor

leibale commented Jan 19, 2023

Blocked by #2373 - will need some updates as this PR changes reconnectStrategy a bit:

  1. It now can be set to false to disable reconnect (instead of a function that always returns an error)
  2. The function now gets a new parameter - cause: unknown - which is the thing that was thrown and triggered reconnect (the type is unknown and not Error because anything is throwable in JS).

@phpbg wanna make these changes or do you prefer I'll do it?

@leibale
Copy link
Contributor

leibale commented Jan 24, 2023

Merging as is, will make the changes in #2373

@leibale leibale merged commit 6642278 into redis:master Jan 24, 2023
florian-schunk pushed a commit to florian-schunk/node-redis that referenced this pull request Jun 18, 2025
* Add 'Network error handling' section to documentation

* Merge 'Network error handling' section with existing doc

* typo

* Update README.md

* typos

Co-authored-by: Samuel CHEMLA <samuel.chemla@orange.com>
Co-authored-by: Leibale Eidelman <me@leibale.com>
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

Successfully merging this pull request may close these issues.

5 participants