redis / redis/node-redis

Uncaught exception: TypeError: Cannot read property 'code' of null at Object.redis.createClient.retry_strategy

Open
#1,159 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

var client = redis.createClient({
    retry_strategy: function (options) {
        if (options.error.code === 'ECONNREFUSED') {
            // End reconnecting on a specific error and flush all commands with a individual error
            return new Error('The server refused the connection');
        }
        if (options.total_retry_time > 1000 * 60 * 60) {
            // End reconnecting after a specific timeout and flush all commands with a individual error
            return new Error('Retry time exhausted');
        }
        if (options.times_connected > 10) {
            // End reconnecting with built in error
            return undefined;
        }
        // reconnect after
        return Math.max(options.attempt * 100, 3000);
    }
});

throw exception:

Uncaught exception:  TypeError: Cannot read property 'code' of null     at Object.redis.createClient.retry_strategy 

log out options:

{ 
  attempt: 1,
  error: null,
  total_retry_time: 0,
  times_connected: 1
 }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the redis.createClient retry_strategy entry point and reproduce the shown configuration, checking the options object when error is null. Done means the retry strategy no longer throws the reported TypeError and the connection retry behavior remains covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, redis
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.