tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 032216be296baeda24895cf5dcc63dfd2c2fcbd6
parent 13df30dc70933d67e2529d05cca5c1ed24c46d18
Author: Jens Stutte <jstutte@mozilla.com>
Date:   Mon, 20 Oct 2025 20:46:45 +0000

Bug 1995383 - Move overzealous shutdown check from WorkerMainThreadRunnable::Run to XMLHttpRequestMainThread::CanSend. r=dom-worker-reviewers,asuth

Bailing from the main thread runnable can break some worker side cleanup waiting for our result. We can instead safely check, if we are not too late to send something to the main thread, as we react accordingly on errors.

Differential Revision: https://phabricator.services.mozilla.com/D269277

Diffstat:
Mdom/workers/WorkerRunnable.cpp | 7-------
Mdom/xhr/XMLHttpRequestMainThread.cpp | 6++++++
2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp @@ -10,7 +10,6 @@ #include "js/RootingAPI.h" #include "jsapi.h" #include "jsfriendapi.h" -#include "mozilla/AppShutdown.h" #include "mozilla/Assertions.h" #include "mozilla/CycleCollectedJSContext.h" #include "mozilla/DebugOnly.h" @@ -637,12 +636,6 @@ NS_IMETHODIMP WorkerMainThreadRunnable::Run() { AssertIsOnMainThread(); - // This shouldn't be necessary once we're better about making sure no workers - // are created during shutdown in earlier phases. - if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) { - return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; - } - bool runResult = MainThreadRun(); RefPtr<MainThreadStopSyncLoopRunnable> response = diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -3074,6 +3074,12 @@ bool XMLHttpRequestMainThread::CanSend(ErrorResult& aRv) { return false; } + // Backstop against late workers. + if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) { + aRv.Throw(NS_ERROR_ILLEGAL_DURING_SHUTDOWN); + return false; + } + return true; }