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.
This option adds an empty error handler
to the Promise to suppress the UnhandledPromiseRejection error. This can be
useful if the deferred Promise is sometimes intentionally not used.
Create a defered Promise.
If the Promise is rejected prior to a handler being added, this can result in an
UnhandledPromiseRejectionerror. Optionally this can be suppressed with thesuppressUnhandledRejectionflag, 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.
Returns
A deferred Promise.