Bug 1544976 - Ignore exceptions thrown while attaching to worker threads, r=loganfsmyth.
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 01 May 2019 07:15:32 -1000
changeset 531111 26916fd0f252f1ea4dfad1206674b9ed7c8791c3
parent 531110 254f28b5aa72908bffdeb155e5ce94d65bbfd234
child 531112 872645a5122c58a40f877a2291e5931a70e507e7
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1544976
milestone68.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 1544976 - Ignore exceptions thrown while attaching to worker threads, r=loganfsmyth.
devtools/client/debugger/src/client/firefox/workers.js
--- a/devtools/client/debugger/src/client/firefox/workers.js
+++ b/devtools/client/debugger/src/client/firefox/workers.js
@@ -21,33 +21,39 @@ export async function updateWorkerClient
   if (!supportsWorkers(tabTarget)) {
     return {};
   }
 
   const newWorkerClients = {};
 
   const { workers } = await tabTarget.listWorkers();
   for (const workerTargetFront of workers) {
-    await workerTargetFront.attach();
-    const [, workerThread] = await workerTargetFront.attachThread(options);
+    try {
+      await workerTargetFront.attach();
+      const [, workerThread] = await workerTargetFront.attachThread(options);
 
-    if (workerClients[workerThread.actor]) {
-      if (workerClients[workerThread.actor].thread != workerThread) {
-        throw new Error(`Multiple clients for actor ID: ${workerThread.actor}`);
+      const actor = workerThread.actor;
+      if (workerClients[actor]) {
+        if (workerClients[actor].thread != workerThread) {
+          console.error(`Multiple clients for actor ID: ${workerThread.actor}`);
+        }
+        newWorkerClients[actor] = workerClients[actor];
+      } else {
+        addThreadEventListeners(workerThread);
+        workerThread.resume();
+
+        const consoleFront = await workerTargetFront.getFront("console");
+        await consoleFront.startListeners([]);
+
+        newWorkerClients[actor] = {
+          url: workerTargetFront.url,
+          thread: workerThread,
+          console: consoleFront
+        };
       }
-      newWorkerClients[workerThread.actor] = workerClients[workerThread.actor];
-    } else {
-      addThreadEventListeners(workerThread);
-      workerThread.resume();
-
-      const consoleFront = await workerTargetFront.getFront("console");
-      await consoleFront.startListeners([]);
-
-      newWorkerClients[workerThread.actor] = {
-        url: workerTargetFront.url,
-        thread: workerThread,
-        console: consoleFront
-      };
+    } catch (e) {
+      // If any of the workers have terminated since the list command initiated
+      // then we will get errors. Ignore these.
     }
   }
 
   return newWorkerClients;
 }