File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,10 +42,30 @@ module.exports = function createClient (options = {}) {
4242 }
4343 } ,
4444
45+ // Any running command that is unfulfilled when a connection is lost should
46+ // NOT be retried after the connection has been reestablished.
47+ retry_unfulfilled_commands : false ,
48+
49+ // If we failed to send a new command during a disconnection, do NOT
50+ // enqueue it to send later after the connection has been [re-]established.
51+ // This is also critical to preventing a backend pile-up!
52+ enable_offline_queue : false ,
53+
4554 // Expand whatever other options and overrides were provided
4655 ...options
4756 } )
4857
58+ // Handle connection errors to prevent killing the Node.js process
59+ client . on ( 'error' , ( connectError ) => {
60+ try {
61+ // Forcibly close the connection to the Redis server.
62+ // Allow all still running commands to silently fail immediately.
63+ client . end ( false )
64+ } catch ( disconnectError ) {
65+ // Swallow any failure
66+ }
67+ } )
68+
4969 // If a `name` was provided, use it in the prefix for logging event messages
5070 const logPrefix = '[redis' + ( name ? ` (${ name } )` : '' ) + ']'
5171
You can’t perform that action at this time.
0 commit comments