Bug 1746648 - Cleanup PromiseHandler error handling r=saschanaz
authorMatthew Gaudet <mgaudet@mozilla.com>
Fri, 14 Jan 2022 21:09:21 +0000
changeset 604607 f18da62311a5c6dc39213cecaff56f03b4bddf0d
parent 604606 8d6d759b2589535ebe6f4df66f29d508186fa4dc
child 604608 1a1f7c796b8f82b85ef186d723b243bf1bae4888
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
bugs1746648
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 1746648 - Cleanup PromiseHandler error handling r=saschanaz Differential Revision: https://phabricator.services.mozilla.com/D135286
dom/streams/ReadableStreamDefaultController.cpp
--- a/dom/streams/ReadableStreamDefaultController.cpp
+++ b/dom/streams/ReadableStreamDefaultController.cpp
@@ -421,28 +421,28 @@ class PullIfNeededNativePromiseHandler f
     // Step 7.1
     mController->SetPulling(false);
     // Step 7.2
     if (mController->PullAgain()) {
       // Step 7.2.1
       mController->SetPullAgain(false);
 
       // Step 7.2.2
-      IgnoredErrorResult rv;
+      ErrorResult rv;
       ReadableStreamDefaultControllerCallPullIfNeeded(
           aCx, MOZ_KnownLive(mController), rv);
-      // Not Sure How To Handle Errors Inside Native Callbacks,
-      (void)NS_WARN_IF(rv.Failed());
+
+      (void)rv.MaybeSetPendingException(aCx);
     }
   }
 
   void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
     // https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed
     // Step 8.1
-    IgnoredErrorResult rv;
+    ErrorResult rv;
     ReadableStreamDefaultControllerError(aCx, mController, aValue, rv);
     (void)rv.MaybeSetPendingException(aCx, "PullIfNeeded Rejected Error");
   }
 };
 
 // Cycle collection methods for promise handler.
 NS_IMPL_CYCLE_COLLECTION(PullIfNeededNativePromiseHandler, mController)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(PullIfNeededNativePromiseHandler)
@@ -521,19 +521,17 @@ class StartPromiseNativeHandler final : 
 
     // Step 11.3
     mController->SetPullAgain(false);
 
     // Step 11.4:
     ErrorResult rv;
     RefPtr<ReadableStreamDefaultController> stackController = mController;
     ReadableStreamDefaultControllerCallPullIfNeeded(aCx, stackController, rv);
-    if (rv.Failed()) {
-      MOZ_CRASH("Error Handling Not Clear Inside Promise Callback");
-    }
+    (void)rv.MaybeSetPendingException(aCx, "StartPromise Resolved Error");
   }
 
   void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
     // https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller
     // Step 12.1
     ErrorResult rv;
     ReadableStreamDefaultControllerError(aCx, mController, aValue, rv);
     (void)rv.MaybeSetPendingException(aCx, "StartPromise Rejected Error");