Bug 1773237 - Mark ignored promise as handled to avoid spurious unhandled rejection error r=evilpie

Differential Revision: https://phabricator.services.mozilla.com/D158589
This commit is contained in:
Matthew Gaudet
2022-10-24 19:53:15 +00:00
parent d3559a2e0d
commit 36b1550bec
3 changed files with 19 additions and 1 deletions

View File

@@ -146,10 +146,16 @@ void FetchStreamReader::CloseAndRelease(JSContext* aCx, nsresult aStatus) {
// comments in ReadableStream::cancel() conveying the spec, step 2 of
// 3.4.3 that specified ReadableStreamCancel is: If stream.[[state]] is
// "closed", return a new promise resolved with undefined.
RefPtr<Promise> ignoredResultPromise =
RefPtr<Promise> cancelResultPromise =
MOZ_KnownLive(mReader)->Cancel(aCx, errorValue, ignoredError);
NS_WARNING_ASSERTION(!ignoredError.Failed(),
"Failed to cancel stream during close and release");
if (cancelResultPromise) {
bool setHandled = cancelResultPromise->SetAnyPromiseIsHandled();
NS_WARNING_ASSERTION(setHandled,
"Failed to mark cancel promise as handled.");
(void)setHandled;
}
}
// We don't want to propagate exceptions during the cleanup.