FGRibreau / FGRibreau/node-request-retry
How to listen to finish of a write stream if requests were retried?
- Dominant language
- JavaScript
- Stars
- 346
- Forks
- 73
- PR merge metrics
- No merged PRs in 30d
Description
I have:
```
return new Promise(resolve => {
request(options)
.pipe(fs.createWriteStream(fileName))
.on("finish", function () {
console.log("The file should be completely written here");
resolve(fileName);
});
});
```
and I expected the `finish` to only be emitted if one of my retryable requests went through.
Instead, if there is a retry, the `finish` will be emitted already for the first request and resolve the promise prematurely.
I want to resolve my Promise if and only if one request was successful and the writing to the stream finished with the content. How do I achieve that?
##
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/38111507-how-to-listen-to-finish-of-a-write-stream-if-requests-were-retried?utm_campaign=plugin&utm_content=tracker%2F1861872&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1861872&utm_medium=issues&utm_source=github).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.