Error UNCERTAIN_STATE with origin ETIMEDOUT and Retry Strategy
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.6k
- Forks
- 2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 40
Description
Issue
Supposed to have a vpn timeout errors, I get this error on the redis client:
{
"code": "UNCERTAIN_STATE",
"command": "GET",
"args": [
"c9903ac70a7b58e1bef3ff0fe2c9dcd0"
],
"origin": {
"errno": "ETIMEDOUT",
"code": "ETIMEDOUT",
"syscall": "read"
}
}
I would like to address it through the retry strategy, but current approach does not seem to work:
retry_strategy: function (options) {
self.logger.warn("RedisStore.retryStragegy %@", options);
if (options && options.error && 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 && 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 && options.times_connected > 10) {
// End reconnecting with built in error
return undefined;
}
// the reconnect retry will happen exactly after this time in milliseconds
return Math.max(options.attempt * 100, 3000);
}
So at this time, as soon as I get the error, the connection fails, and if the VPN turns on, node-redis will hang for ever.
Environment
- v12.16.1
- Redis 5.0.3
- macOS 10.14.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the VPN timeout with the retry_strategy shown, then inspect node-redis retry handling for UNCERTAIN_STATE and ETIMEDOUT. Done means the client does not hang indefinitely and reconnects or reports a final error according to the configured retry strategy after the VPN is restored.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, redis
- Domain
- backend, databases, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100