diff --git a/dom/cookiestore/CookieStoreNotificationWatcherWrapper.cpp b/dom/cookiestore/CookieStoreNotificationWatcherWrapper.cpp index c83e82d459e6..c2f0d282101e 100644 --- a/dom/cookiestore/CookieStoreNotificationWatcherWrapper.cpp +++ b/dom/cookiestore/CookieStoreNotificationWatcherWrapper.cpp @@ -129,6 +129,11 @@ void CookieStoreNotificationWatcherWrapper::ResolvePromiseWhenNotified( workerPrivate, "CookieStoreNotificationWatcher::PromiseResolver", [resolver = RefPtr(resolver)]() { resolver->Run(); }); + if (!strongWorkerRef) { + // The worker is already shutting down. Let's ignore this promise. + return; + } + workerRef = new ThreadSafeWorkerRef(strongWorkerRef); }