Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixed devtools url used for debug with chrome and edge #61813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Dona278
Copy link
Contributor

@Dona278 Dona278 commented May 6, 2025

This PR ensure the correct creation of the devtools url with proxy to use for debug with chrome and edge browser which recently changed how urls are returned from "localhost:9222/json".

Browser tested:
Edge Version 136.0.3240.50
Chrome Version 136.0.7103.49

Fixes #61559

@Dona278 Dona278 requested a review from a team as a code owner May 6, 2025 15:36
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label May 6, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 6, 2025
Copy link
Contributor

Thanks for your PR, @@Dona278. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Comment on lines +391 to +393
localPath = localPath.Split('/').Last().TrimStart('/');
// Ensure starts with "devtools"
localPath = $"devtools/{localPath}";
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand this logic, looking at the previous code, we simply concatenated the devToolsFrontendUrl, why do we need to remove any segments but the last from the path?

Copy link
Contributor Author

@Dona278 Dona278 May 6, 2025

Choose a reason for hiding this comment

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

Because the current url is in this format https://chrome-devtools-frontend.appspot.com/serve_rev/@031848bc6ad02b97854f3d6154d3aefd0434756a/inspector.html?ws=..... so the local path will be serve_rev/@xxxxxxx/inspector.html.

The previous one I suppose was like devtools/inspector.html?ws=....., so I take the last segment which is the inspector page of the browser returned by the browser (to avoid hardcode the name) and then add the missing segment devtools/ at the begin.
But after write that, now I think that if I can hardcoded devtools/ I can hardcode directly devotools/inspector.html too..

Copy link
Member

@javiercn javiercn May 6, 2025

Choose a reason for hiding this comment

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

I apologize it might not be my brightest day, but I'm not following. In the past we would concatenate the relative URL that came back with the _browserHost; if the URL that we receive is absolute now, I don't understand why stripping the host+scheme is not enough. In other words, why making the url relative is not enough

The part that I don't follow is why we didn't have to strip a part of the path in the previous version, and we need to do so now.

@thaystg do you have thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

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

@Dona278 can you please provide the difference between the localhost:9222/json of the browser that you are using and an older version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I cannot downgrade chrome to older version I found the "old" value here:

[{
  "description": "",
  "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/DAB7FB6187B554E10B0BD18821265734",
  "id": "DAB7FB6187B554E10B0BD18821265734",
  "title": "Yahoo",
  "type": "page",
  "url": "https://www.yahoo.com/",
  "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/DAB7FB6187B554E10B0BD18821265734"
}]

the "new" one:

[
  {
    "description": "",
    "devtoolsFrontendUrl": "https://chrome-devtools-frontend.appspot.com/serve_rev/@031848bc6ad02b97854f3d6154d3aefd0434756a/inspector.html?ws=localhost:9222/devtools/page/719FE9D3B43570193235446E0AB36859",
    "id": "719FE9D3B43570193235446E0AB36859",
    "title": "Blazor Application",
    "type": "page",
    "url": "http://localhost:9222/json",
    "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/719FE9D3B43570193235446E0AB36859"
  }
]

Copy link
Member

Choose a reason for hiding this comment

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

@javiercn with the diff do you agree with the changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I created confusion about "new" and "old" urls, I'm sorry.. as we can see in these two json not only changed from relative to absolute but changed also the path, so make the new-absolute-one relative isn't enough..
However I agree with changes suggested by @ilonatommy which maybe create less confusion if the user doesn't read Uri.TryCreate(UriKind.Absolute) and cover both old and new version..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blazor WebAssembly browser debugging fails with UriFormatException using recent Chrome versions
4 participants