Skip to content

Remove --forward-console support from wasm/browser app host - #130819

Merged
pavelsavara merged 4 commits into
dotnet:mainfrom
pavelsavara:remove-host-forward-console
Jul 16, 2026
Merged

pavelsavara merged 4 commits into
dotnet:mainfrom
pavelsavara:remove-host-forward-console

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

Removes the --forward-console flag (and its supporting infrastructure) from the WebAssembly app host (src/mono/wasm/host/).

The app host's --forward-console flag set up a WebSocket /console endpoint that received browser console messages — forwarded over a WebSocket by the JS runtime (config.forwardConsole) — and printed them to the host stdout. This was primarily a workaround for Firefox, since chromedriver/Playwright forward browser console output natively.

Changes

Host-side removal (full):

  • BrowserArguments.cs — removed the --forward-console CLI option, ForwardConsoleOutput property, and its JSON property parsing.
  • RunArgumentsJson.cs — removed the forwardConsole field (no longer written to runArgs.json).
  • BrowserHost.cs — removed the onConsoleConnected wiring, the RunConsoleMessagesPump method, and the OnConsoleConnected args from the server-option factories.
  • WebServerOptions.cs / DevServer/DevServerOptions.cs — dropped the OnConsoleConnected member.
  • WebServerStartup.cs / DevServer/DevServerStartup.cs — removed the /console WebSocket endpoints.
  • Deleted WasmTestMessagesProcessor.cs and its only-consumer WasmLogMessage.cs.

Kept in place (intentionally out of scope):

  • JS side — config.forwardConsole handling in the browser runtime loader, test-main.mjs, etc.
  • xharness side — its own /console handler and message processor.

Impacted tests rewired:

  • InterpPgoTests and WasmTemplateTests were the only in-repo consumers of dotnet run --forward-console. Both run in Chrome via Playwright and previously read the app's console output from the host stdout. They now capture browser console output into BrowserRunner.OutputLines via page.Console (native chromedriver/Playwright forwarding), so they no longer depend on the host flag.

Firefox scenarios

All Firefox-relevant console forwarding lives on the JS + xharness side, which is untouched. The commented-out Firefox run-only sample work items in sendtohelix-browser.targets and the WasmTestForwardConsole note in BuildEnvironment.cs reference the xharness/JS path, not the host CLI flag, so they are unaffected.

Note

This PR description was generated with the assistance of GitHub Copilot.

The app host's --forward-console flag set up a WebSocket /console endpoint that received browser console messages (forwarded over WebSocket by the JS runtime) and printed them to the host stdout. This was primarily a workaround for Firefox, since chromedriver/Playwright forward console output natively.

Removes the host-side mechanism entirely: the --forward-console CLI option and ForwardConsoleOutput/forwardConsole plumbing, the OnConsoleConnected wiring, the /console endpoints in WebServer/DevServer, and the WasmTestMessagesProcessor/WasmLogMessage types.

The JS side (config.forwardConsole) and the xharness side (its own /console handler) are kept in place.

Rewires the only in-repo consumers (InterpPgoTests and WasmTemplateTests, both Chrome/Playwright) to capture browser console output into BrowserRunner.OutputLines via page.Console instead of relying on host forwarding.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the --forward-console option and the host-side WebSocket /console forwarding plumbing from the wasm/browser app host, and updates wasm build tests to rely on Playwright’s native browser-console forwarding instead of the host flag.

Changes:

  • Removed /console WebSocket endpoint support from the app host’s web server + dev server startup paths and options wiring.
  • Stopped writing forwardConsole into runArgs.json and removed the associated host-configuration parsing.
  • Updated Playwright-based wasm build tests to drop --forward-console and capture browser console output via page.Console.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs Drops --forward-console from dotnet run invocations used by template tests.
src/mono/wasm/Wasm.Build.Tests/InterpPgoTests.cs Drops --forward-console from dotnet run invocation used by interpreter PGO test.
src/mono/wasm/Wasm.Build.Tests/BrowserRunner.cs Captures Playwright page.Console output into OutputLines to replace reliance on host forwarding.
src/mono/wasm/host/WebServerStartup.cs Removes /console WebSocket route wiring from the legacy web server startup.
src/mono/wasm/host/WebServerOptions.cs Removes the OnConsoleConnected callback from the web server options record.
src/mono/wasm/host/RunArgumentsJson.cs Removes the forwardConsole field from serialized runArgs.json.
src/mono/wasm/host/DevServer/DevServerStartup.cs Removes /console WebSocket interception from the dev server startup pipeline.
src/mono/wasm/host/DevServer/DevServerOptions.cs Removes the OnConsoleConnected callback from the dev server options record.
src/mono/wasm/host/BrowserHost.cs Removes console-forwarding wiring, related factories, and runArgs.json emission for forwardConsole.
src/mono/wasm/host/BrowserArguments.cs Removes the --forward-console CLI option + JSON property parsing.
src/mono/wasm/host/WasmTestMessagesProcessor.cs Deleted (host-side message processing for forwarded console WebSocket payloads).
src/mono/wasm/host/WasmLogMessage.cs Deleted (data contract for forwarded console messages).

@pavelsavara pavelsavara added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Jul 15, 2026
@pavelsavara pavelsavara added this to the 11.0.0 milestone Jul 15, 2026
@pavelsavara
pavelsavara temporarily deployed to copilot-pat-pool July 15, 2026 20:48 — with GitHub Actions Inactive
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@pavelsavara
pavelsavara temporarily deployed to copilot-pat-pool July 15, 2026 20:48 — with GitHub Actions Inactive
@pavelsavara
pavelsavara marked this pull request as ready for review July 16, 2026 09:53
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings July 16, 2026 10:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Comment thread src/mono/wasm/host/BrowserArguments.cs Resolved
Copilot AI review requested due to automatic review settings July 16, 2026 10:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment thread src/mono/wasm/host/BrowserArguments.cs Resolved
@pavelsavara
pavelsavara merged commit f9116f0 into dotnet:main Jul 16, 2026
50 checks passed
@pavelsavara
pavelsavara deleted the remove-host-forward-console branch July 16, 2026 12:33
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants