Bug 1746647 - Remove un-necessary callback error wrapping (redux) r=saschanaz
authorMatthew Gaudet <mgaudet@mozilla.com>
Fri, 14 Jan 2022 21:09:21 +0000
changeset 604606 8d6d759b2589535ebe6f4df66f29d508186fa4dc
parent 604605 f83f8d048441ce3c353c06f988bf63843f14ee27
child 604607 f18da62311a5c6dc39213cecaff56f03b4bddf0d
push id39152
push userabutkovits@mozilla.com
push dateSat, 15 Jan 2022 09:45:36 +0000
treeherdermozilla-central@60998033086a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssaschanaz
bugs1746647
milestone98.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1746647 - Remove un-necessary callback error wrapping (redux) r=saschanaz Differential Revision: https://phabricator.services.mozilla.com/D135285
dom/streams/ReadableStreamDefaultController.cpp
--- a/dom/streams/ReadableStreamDefaultController.cpp
+++ b/dom/streams/ReadableStreamDefaultController.cpp
@@ -476,50 +476,22 @@ static void ReadableStreamDefaultControl
 
   // Step 5.
   aController->SetPulling(true);
 
   // Step 6.
   RefPtr<UnderlyingSourcePullCallbackHelper> pullAlgorithm(
       aController->GetPullAlgorithm());
 
-  // Pre-allocate a promise which we may end up discarding or rejecting.
-  // We do this here in order to avoid having to try allocating on a
-  // failure path after the callback is called.
-  RefPtr<Promise> maybeRejectPromise =
-      Promise::Create(aController->GetParentObject(), aRv);
-  if (aRv.Failed()) {
-    return;
-  }
-
   RefPtr<Promise> pullPromise =
       pullAlgorithm ? pullAlgorithm->PullCallback(aCx, *aController, aRv)
                     : Promise::CreateResolvedWithUndefined(
                           aController->GetParentObject(), aRv);
-
-  // The below failure handling code is all about implmenting WebIDL promise
-  // rejection semantics until
-  // https://bugzilla.mozilla.org/show_bug.cgi?id=1726595 is fixed.
-  //
-  // Since this function can be called as part of a native promise handler,
-  // which has no way right now to signal error, and to ape what we do in the SM
-  // Streams implementation,
-  //  https://searchfox.org/mozilla-central/source/js/src/builtin/streams/MiscellaneousOperations-inl.h#37
-  //
-
-  // Inform the ErrorResult that we're handling a JS exception if it happened.
-  aRv.WouldReportJSException();
-
-  // We want to convert callback throw to a rejected promise.
   if (aRv.Failed()) {
-    MOZ_ASSERT(!pullPromise);
-
-    // Use the previously allocated promise now.
-    pullPromise = maybeRejectPromise;
-    pullPromise->MaybeReject(std::move(aRv));
+    return;
   }
 
   // Step 7 + 8:
   pullPromise->AppendNativeHandler(
       new PullIfNeededNativePromiseHandler(aController));
 }
 
 class StartPromiseNativeHandler final : public PromiseNativeHandler {