[wasm][debugger] Proxy but don't process events from worker sessions (#57990)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 24 Aug 2021 19:25:36 +0000 (15:25 -0400)
committerGitHub <noreply@github.com>
Tue, 24 Aug 2021 19:25:36 +0000 (15:25 -0400)
Backport of #57974

Should Fix #57949

Co-authored-by: Larry Ewing <lewing@microsoft.com>
src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs

index 95aa6de..1f8c498 100644 (file)
@@ -126,7 +126,11 @@ namespace Microsoft.WebAssembly.Diagnostics
 
                 case "Runtime.exceptionThrown":
                     {
-                        if (!GetContext(sessionId).IsRuntimeReady)
+                        // Don't process events from sessions we aren't tracking
+                        if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
+                            return false;
+
+                        if (!context.IsRuntimeReady)
                         {
                             string exceptionError = args?["exceptionDetails"]?["exception"]?["value"]?.Value<string>();
                             if (exceptionError == sPauseOnUncaught || exceptionError == sPauseOnCaught)
@@ -139,7 +143,11 @@ namespace Microsoft.WebAssembly.Diagnostics
 
                 case "Debugger.paused":
                     {
-                        if (!GetContext(sessionId).IsRuntimeReady)
+                        // Don't process events from sessions we aren't tracking
+                        if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
+                            return false;
+
+                        if (!context.IsRuntimeReady)
                         {
                             string reason = args?["reason"]?.Value<string>();
                             if (reason == "exception")
@@ -148,13 +156,13 @@ namespace Microsoft.WebAssembly.Diagnostics
                                 if (exceptionError == sPauseOnUncaught)
                                 {
                                     await SendCommand(sessionId, "Debugger.resume", new JObject(), token);
-                                    GetContext(sessionId).PauseOnUncaught = true;
+                                    context.PauseOnUncaught = true;
                                     return true;
                                 }
                                 if (exceptionError == sPauseOnCaught)
                                 {
                                     await SendCommand(sessionId, "Debugger.resume", new JObject(), token);
-                                    GetContext(sessionId).PauseOnCaught = true;
+                                    context.PauseOnCaught = true;
                                     return true;
                                 }
                             }