Skip to content

Commit

Permalink
Bring back the command timeout
Browse files Browse the repository at this point in the history
We need a timeout in case a host goes away or stops responding.
  • Loading branch information
joshbetz committed Dec 10, 2022
1 parent 14a5713 commit 3fd3f0f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/memcached.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ export default class Memcached extends EventEmitter {
}

this.client.write( command );

setTimeout( () => {
this.client.removeAllListeners();
reject( new Error( 'Command Timeout' ) );
}, Math.max( this.opts.socketTimeout, 1000 ) ).unref();
} );
}

Expand Down

0 comments on commit 3fd3f0f

Please sign in to comment.