Don't stop all collectors if one fails#13
Open
liamphmurphy wants to merge 6 commits into
Open
Conversation
mindblight
reviewed
Sep 5, 2022
mindblight
left a comment
There was a problem hiding this comment.
I know a lot about JS and promises, but I'm new to CodeForPX so I don't feel quite ready to push approve :)
Comment on lines
+83
to
+89
| // Do not reject all promises when one of them is rejected, but do output why one was rejected. | ||
| Promise.allSettled(promises) | ||
| .then((results) => results.forEach((result) => { | ||
| if(result.status == "rejected") { | ||
| console.log("received a rejected promise with reason: " + result.reason) | ||
| } | ||
| })); |
There was a problem hiding this comment.
💬 This works great. You can also use Javascript's async/await for the same effect:
const results = await promises;
for (const result of results) {
if (result.status === "rejected") {
...
}
}Co-authored-by: Arion Sprague <mindblight@users.noreply.github.com>
mindblight
reviewed
Sep 10, 2022
| } | ||
| console.log("wrote", fileName) | ||
| }); | ||
| return writeFile(fileName, JSON.stringify(data)) |
There was a problem hiding this comment.
❓ Does this work without importing writeFile?
import { writeFile } from 'fs/promises';`
There was a problem hiding this comment.
Ah, sorry. Just realized this project is using CommonJS.
const { writeFile } = require('fs/promises);
Contributor
Author
There was a problem hiding this comment.
Yep the second way seems to work as expected, thanks for the suggestion 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.