Bug 1786571 Comment 15 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

So from the pernosco session we see that there is a strong worker ref that is never unset. For the scriptloader in question we never called [`WorkerScriptLoader::TryShutdown` or `::ShutdownScriptLoader`](https://searchfox.org/mozilla-central/rev/0948667bc62415d48abff27e1405fb4ab4d65d75/dom/workers/ScriptLoader.cpp#1008) which seems to be the only place where we unset the worker ref. Instead we called `WorkerScriptLoader::CancelMainThreadWithBindingAborted`.

Could it be that we should do something like:

```
void WorkerScriptLoader::CancelMainThread(
    nsresult aCancelResult, nsTArray<WorkerLoadContext*>* aContextList) {
  AssertIsOnMainThread();
  {
    MutexAutoLock lock(CleanUpLock());

    // Check if we have already cancelled, or if the worker has been killed
    // before we cancel.
    if (IsCancelled() || CleanedUp()) {
      return;
    }

    mCancelMainThread = Some(aCancelResult);

    // In the case of a cancellation, service workers fetching from the
    // cache will still be doing work despite CancelMainThread. Eagerly
    // clear the promises associated with these scripts.
    for (WorkerLoadContext* loadContext : *aContextList) {
      if (loadContext->IsAwaitingPromise()) {
        loadContext->mCachePromise->MaybeReject(NS_BINDING_ABORTED);
        loadContext->mCachePromise = nullptr;
      }
    }

    // Ensure we did release our worker ref
    ShutdownScriptLoader(false, false);
  }
}
```
So from the pernosco session we see that there is a strong worker ref that is never unset. For the scriptloader in question we never called [`WorkerScriptLoader::TryShutdown` or `::ShutdownScriptLoader`](https://searchfox.org/mozilla-central/rev/0948667bc62415d48abff27e1405fb4ab4d65d75/dom/workers/ScriptLoader.cpp#1008) which seems to be the only place where we unset the worker ref. Instead we called `WorkerScriptLoader::CancelMainThreadWithBindingAborted`.

Back to Bug 1786571 Comment 15