mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
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:
parent
0333dda462
commit
242794868d
@ -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.
|
||||
|
11
dom/streams/test/xpcshell/bug-1773237.js
Normal file
11
dom/streams/test/xpcshell/bug-1773237.js
Normal file
@ -0,0 +1,11 @@
|
||||
// This test fails if there is an unhandled promise rejection
|
||||
var stream = new ReadableStream({
|
||||
pull() {
|
||||
return Promise.reject("foobar");
|
||||
},
|
||||
});
|
||||
var response = new Response(stream);
|
||||
var text = response.text().then(
|
||||
() => {},
|
||||
e => {}
|
||||
);
|
@ -19,3 +19,4 @@ skip-if =
|
||||
tsan # Causes claim expired errors; see Bug 1770170.
|
||||
run-sequentially = very high failure rate in parallel
|
||||
[too-big-array-buffer.js]
|
||||
[bug-1773237.js]
|
||||
|
Loading…
Reference in New Issue
Block a user