From a5369fa3807cec875ceaaaaf2502a7c51c3dbbf3 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Sat, 17 Sep 2022 14:06:47 -0400 Subject: [PATCH] [wasm] Misc improvements (#951) --- .../WASM/Browser/WasmTestBrowserCommand.cs | 28 +++++++++++-------- .../WASM/WasmTestMessagesProcessor.cs | 5 ++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs b/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs index 252413cc5..04946a1a5 100644 --- a/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs +++ b/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs @@ -200,17 +200,23 @@ protected override async Task InvokeInternal(ILogger logger) options.AddArguments(new[] { - // added based on https://github.com/puppeteer/puppeteer/blob/main/src/node/Launcher.ts#L159-L181 - "--allow-insecure-localhost", - "--disable-breakpad", - "--disable-component-extensions-with-background-pages", - "--disable-dev-shm-usage", - "--disable-extensions", - "--disable-features=TranslateUI", - "--disable-ipc-flooding-protection", - "--force-color-profile=srgb", - "--metrics-recording-only" - }); + // added based on https://github.com/puppeteer/puppeteer/blob/main/src/node/Launcher.ts#L159-L181 + "--allow-insecure-localhost", + "--disable-breakpad", + "--disable-component-extensions-with-background-pages", + "--disable-dev-shm-usage", + "--disable-extensions", + "--disable-features=TranslateUI", + "--disable-ipc-flooding-protection", + "--force-color-profile=srgb", + "--metrics-recording-only" + }); + + if (File.Exists("/.dockerenv")) + { + // Use --no-sandbox for containers, and codespaces + options.AddArguments("--no-sandbox"); + } if (Arguments.NoQuit) options.LeaveBrowserRunning = true; diff --git a/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/WasmTestMessagesProcessor.cs b/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/WasmTestMessagesProcessor.cs index f64eddc58..d26d0a588 100644 --- a/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/WasmTestMessagesProcessor.cs +++ b/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/WasmTestMessagesProcessor.cs @@ -72,7 +72,7 @@ public async Task RunAsync(CancellationToken token) } catch (Exception ex) { - _channelWriter.TryComplete(); + _channelWriter.TryComplete(ex); // surface the exception from task for this method // and from _completed @@ -195,7 +195,8 @@ private void ProcessMessage(string message, bool isError = false) if (line.StartsWith("WASM EXIT")) { _logger.LogDebug("Reached wasm exit"); - WasmExitReceivedTcs.SetResult(); + if (!WasmExitReceivedTcs.TrySetResult()) + _logger.LogDebug("Got a duplicate exit message."); } }