Skip to content

WithBrowserDebugger: no-op when IDE lacks browser capability#15400

Open
adamint wants to merge 2 commits intomicrosoft:release/13.2from
adamint:dev/adamint/js-hosting-extensions-13.2
Open

WithBrowserDebugger: no-op when IDE lacks browser capability#15400
adamint wants to merge 2 commits intomicrosoft:release/13.2from
adamint:dev/adamint/js-hosting-extensions-13.2

Conversation

@adamint
Copy link
Member

@adamint adamint commented Mar 19, 2026

Description

WithBrowserDebugger previously always created a BrowserDebuggerResource child resource, even when the IDE didn't support browser debugging (i.e., DEBUG_SESSION_INFO was not set or didn't include "browser" in supported_launch_configurations). This caused unnecessary resources to be created.

This change makes WithBrowserDebugger a no-op when the IDE lacks browser capability:

  • Renames ValidateBrowserCapabilityHasBrowserCapability (returns bool instead of void)
  • WithBrowserDebugger early-returns without creating the child resource when HasBrowserCapability returns false
  • Still throws InvalidOperationException when DEBUG_SESSION_INFO is present but doesn't list "browser" capability

Testing

  • Updated 4 existing browser debugger tests to set DEBUG_SESSION_INFO with browser capability
  • Added 2 new tests:
    • ViteApp_WithBrowserDebugger_NoOps_WhenDebugSessionInfoNotSet — verifies no child resource when config is absent
    • ViteApp_WithBrowserDebugger_NoOps_WhenBrowserCapabilityNotListed — verifies exception when config exists but browser isn't listed
  • All 103 JS hosting tests pass

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

- Rename ValidateBrowserCapability to HasBrowserCapability (returns bool)
- WithBrowserDebugger early-returns when DEBUG_SESSION_INFO is missing or
  doesn't include 'browser' capability, instead of always creating the
  child resource
- Update existing tests to set DEBUG_SESSION_INFO with browser capability
- Add tests for no-op behavior and unsupported capability error
Copilot AI review requested due to automatic review settings March 19, 2026 19:19
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15400

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15400"

Copy link
Contributor

Copilot AI left a comment

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 updates JavaScript hosting’s WithBrowserDebugger behavior so it doesn’t create a BrowserDebuggerResource unless the IDE indicates browser debugging support via DEBUG_SESSION_INFO, and adjusts tests accordingly.

Changes:

  • Make WithBrowserDebugger early-return (no-op) when browser capability isn’t available (HasBrowserCapability).
  • Rename/reshape the capability check from ValidateBrowserCapability (void) to HasBrowserCapability (bool) and keep throwing when capability info is present but lacks "browser".
  • Update/add unit tests to set DEBUG_SESSION_INFO where required and to cover the no-op case.

Reviewed changes

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

File Description
src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs Adds capability gating for WithBrowserDebugger via HasBrowserCapability and updates docs.
tests/Aspire.Hosting.JavaScript.Tests/AddNodeAppTests.cs Updates existing browser debugger tests to set DEBUG_SESSION_INFO and adds new tests for no-op/throw cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants