Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unhandled Promise rejections in pipeline.exec
1. Always return the same Promise in pipeline.exec. An example of why the original Promise should be returned, rather than a different Promise resolving to the original Promise: ```javascript process.on('unhandledRejection', (reason) => console.log('unhandledRejection', reason)); const x = Promise.reject(new Error()); x.catch((e) => console.log('caught x', e)); const causesUnhandledRejection = Promise.resolve().then(() => x); ``` 2. In the negligible chance the `script exists`/`script load` command failed, give up, catch the rejected Promise with `finally`, and try to run the commands in the pipeline anyway. (e.g. networking issues, corrupted bytes, etc) This isn't the best approach, but it's hopefully better than an unhandled Promise rejection, resource/memory leak, or hanging request due to a redis Promise never resolving or rejecting for an individual command in this edge case. 3. There are calls to `this.exec(...);` all over the Pipeline that don't check if the returned Promise is caught which I believe could lead to unhandled Promise rejections on retrying failed commands. Also, lib/autopipelining.js also called pipeline.exec without checking for errors. The fact there is now exactly one Promise instance that can be returned means that this no longer can cause unhandled Promise rejections. (see example snippet in commit description) (`standard-as-callback` is catching rejections) 4. pipeline.exec can explicitly call reject for ioredis's Redis.Cluster client
- Loading branch information