microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.97k stars 29.19k forks source link

serverReadyAction doesn't launch browser on VS Code with FormatterName set to json #185295

Closed terryaney closed 1 year ago

terryaney commented 1 year ago

Type: Bug

Here is my appsettings.json:

{
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft.AspNetCore": "Warning",
            "System.Net.Http": "None"
        },
        "Console": {
            "FormatterName": "json",
            "FormatterOptions": {
                "SingleLine": true,
                "IncludeScopes": true,
                "TimestampFormat": "HH:mm:ss",
                "UseUtcTimestamp": true,
                "JsonWriterOptions": {
                    "Indented": true
                }
            }
        }
    },

    "AllowedHosts": "*"
}

Here is my launch.json serverReadyAction settings (let me know if anything else in launch.json is relevant).

"serverReadyAction": {
    "action": "debugWithChrome",
    "pattern": "\\bNow listening on:\\s+(https?://\\S+)",
    "uriFormat": "%s/app/channel-home",
    "killOnServerStop": true
},

So, if I don't use a json formatter, it works fine. When I use a formatter, it doesn't work. Here is the console output when I debug my site.

{
  "Timestamp": "04:25:54",
  "EventId": 14,
  "LogLevel": "Information",
  "Category": "Microsoft.Hosting.Lifetime",
  "Message": "Now listening on: https://localhost:7058",
  "State": {
    "Message": "Now listening on: https://localhost:7058",
    "address": "https://localhost:7058",
    "{OriginalFormat}": "Now listening on: {address}"
  },
  "Scopes": []
}
Microsoft.Hosting.Lifetime: Information: Now listening on: https://localhost:7058

(obviously 2 entries because of the Debug Console displaying 'Console' and 'Debug' output)

I've tried changing my pattern to the following and none worked (admittedly, my RegEx skills are weak):

"Now listening on:\\s+(https?://\\S+)" "(\\b|\")Now listening on:\\s+(https?://\\S+)" ".*Now listening on:\\s+(https?://\\S+)"

VS Code version: Code 1.79.1 (4cb974a7aed77a74c7813bdccd99ee0d04901215, 2023-06-12T16:14:05.102Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|63.70GB (45.31GB free)| |Process Argv|--crash-reporter-id 3a73b254-9ee7-4cb6-b1eb-57f9149a1430| |Screen Reader|no| |VM|0%|
Extensions (19) Extension|Author (truncated)|Version ---|---|--- vs-code-intellisense-katapp|con|1.0.5 xml|Dot|2.5.1 gitlens|eam|14.0.0 vscode-firefox-debug|fir|2.9.8 dotnet-test-explorer|for|0.7.8 copilot|Git|1.89.156 copilot-chat|Git|0.3.2023060801 copilot-labs|Git|0.14.884 rest-client|hum|0.25.1 theme-monokai-pro-vscode|mon|1.2.1 csharp|ms-|1.25.9 vscode-dotnet-runtime|ms-|1.6.0 vscode-nuget-gallery|pat|0.0.24 postman-for-vscode|Pos|0.3.0 vscode-css-peek|pra|4.2.0 LiveServer|rit|5.7.9 vscode-autohotkey2-lsp|thq|2.0.4 vscode-icons|vsc|12.4.0 volar|Vue|1.6.4
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 vsclangdc:30486549 c4g48928:30535728 dsvsc012cf:30540253 pynewext54:30695312 azure-dev_surveyone:30548225 2e4cg342:30602488 pyind779:30671433 89544117:30613380 pythonsymbol12:30671437 showlangstatbar:30737416 vsctsb:30748421 pythonms35:30701012 03d35959:30757346 pythonfmttext:30731395 pythoncmv:30756943 fixshowwlkth:30730052 pythongtdpath:30769146 dh2dc718:30763024 ```
vscodenpa commented 1 year ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.79.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

terryaney commented 1 year ago

Upgraded to latest and problem remains.

roblourens commented 1 year ago

This is working for me when I use a node app that outputs that exact text. Your regex looks fine. Can you share the full launch config?

An easy way to debug it would be to first trim down your pattern- "e" or "." should definitely match- then build it back up and see what breaks it

vscodenpa commented 1 year ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

terryaney commented 1 year ago

@roblourens Had crazy week at work. Was going to try and create a branch this weekend. Is this closed and I have to start over or you are able to reopen?

terryaney commented 1 year ago

@roblourens Here is my full config:

        {
            // Use IntelliSense to find out which attributes exist for C# debugging
            // Use hover for the description of the existing attributes
            // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
            "name": "Site+Proxy",
            "presentation": { "hidden": true },
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "logging": {
                "moduleLoad": false
            },
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/bin/Debug/net7.0/Nexgen.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,            
            // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
            "serverReadyAction": {
                "action": "debugWithChrome",                              
                "pattern": "\\bNow listening on:\\s+(https?://\\S+)",
                "uriFormat": "%s/app/channel-home?siteKey=GOLD&iam_=011391001&lp=0&tracesavanna=0&apidebug=ApiProxy,RBLe_,DocGen_&rblcache=1&tracekatapp=0&DataSource=0",
                "killOnServerStop": true
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            },
            "launchSettingsProfile": "Site"            
        },
terryaney commented 1 year ago

After some experimenting, I was able to get it to work with:

"pattern": "\"address\": \"(https?://\\S+)\""

Let me know if there is a better way :)

roblourens commented 1 year ago

Not sure why the previous one wouldn't work for you, but this one also looks valid 👍