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

docs: Add caution about suppressing errors #174

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ export type DeferredPromise<Result = void> = {
/**
* Create a defered Promise.
*
* If the Promise is rejected prior to a handler being added, this can result in an
* `UnhandledPromiseRejection` error. Optionally this can be suppressed with the
* `suppressUnhandledRejection` flag, as it's common to belatedly handle deferred Promises, or to
* ignore them if they're no longer relevant (e.g. related to a cancelled request).
*
* However, be very careful that you have handled the Promise if you do this. Suppressing these
* errors is dangerous, they exist for good reason. An unhandled rejection can hide errors, making
* debugging extremely difficult. They should only be suppressed if you're confident that the
* Promise is always handled correctly, in both the success and failure cases.
*
* @param args - The arguments.
* @param args.suppressUnhandledRejection - This option adds an empty error handler
* to the Promise to suppress the UnhandledPromiseRejection error. This can be
Expand Down
Loading