Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing throwOnError option for comprehensive promise chain results #70

Open
fr1sk opened this issue Jan 4, 2024 · 2 comments
Open

Comments

@fr1sk
Copy link

fr1sk commented Jan 4, 2024

I think this package is missing an important functionality, and that is to see the results of resolved promises when one of the promises from the promise chain gets rejected. When stopOnError is set to false if some of the promises are rejected, I am not able to get fulfilled results, instead, the error is thrown.

It would be good to have similar behavior like Promise.allSettled to see the results of the promises and their status. EG if resolved, we can see the resolved result and if rejected we can see the error.

Maybe we can have an additional option, throwOnError which will be true by default to not break the functionality, but have the ability to have the functionality explained above.

I am happy to open a PR if you would like to include this functionality in your package.

@sindresorhus
Copy link
Owner

I agree that this functionality would be useful, but I'm not 100% sure about the throwOnError option. It's a bit too similar sounding to the existing stopOnError option. We could make the behavior clear in the docs, but I would still like to brainstorm some alternatives. I do think it should be an option and not separate methods.

For now, you could use p-reflect with p-map.

@fr1sk
Copy link
Author

fr1sk commented Jan 15, 2024

I agree that it sounds similar to stopOnError but the functionality is different, also it may change the way how pMap works since it will return different things in case this option is passed (similar to Promise.allSettled response). Maybe the better option is to create a new function pMapSettled that will be similar to Promise.allSettled but have the functionality of pMap like the option to choose a number of parallel executions.

I will create a PoC package and let you review it so that later on we can include that in your repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants