From fff73b0151983f93ec350dbe057e317219306563 Mon Sep 17 00:00:00 2001 From: Dan Minor Date: Tue, 5 Jul 2022 23:33:54 +0000 Subject: [PATCH] Bug 1771858 - Handle interrupt in AsyncModuleExecutionFulfilled; r=jonco In AsyncModuleExecutionFulfilled, it's possible that the call to GatherAsyncParentCompletions will fail if we are interrupted. The current code assumes that this is only reachable as a result of an OOM. This changes the assertion to an if statement to handle being interrupted. Differential Revision: https://phabricator.services.mozilla.com/D147954 --- js/src/builtin/ModuleObject.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index 1fd2361bbb25..413a9beac330 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -2311,9 +2311,13 @@ void js::AsyncModuleExecutionFulfilled(JSContext* cx, Rooted sortedList(cx); if (!GatherAvailableModuleAncestors(cx, module, &sortedList)) { - // We have OOM'd -- all bets are off, reject the promise. Not much more we - // can do. - MOZ_ASSERT(cx->isExceptionPending()); + // We have been interrupted or have OOM'd -- all bets are off, reject the + // promise. Not much more we can do. + if (!cx->isExceptionPending()) { + AsyncModuleExecutionRejected(cx, module, UndefinedHandleValue); + return; + } + RootedValue exception(cx); if (!cx->getPendingException(&exception)) { return;