ionic-team / vscode-ionic

Visual Studio Code Ionic Extension
Other
10 stars 1 forks source link

Debugger stops when redirecting through auth flow #140

Open robjackstewart opened 8 months ago

robjackstewart commented 8 months ago

Im writing my first ionic app and Im using the auth0 framework as demonstrated here. However, due to the use of Browser.open({ url, windowName: '_self' }); when I go through the auth flow, the debugger dies due to being disconnected from the running instance of the app.

Is there a way to keep the debugger running such that it reattaches upon redirect back to the app?

robjackstewart commented 8 months ago

So I have managed to get this working via a workaround not using the ionic VSCode extension by using the following VSCode debug setup:

// tasks.json
{
    "tasks": [
        {
            "label": "Start development server",
            "type": "shell",
            "isBackground": true,
            "command": "npx",
            "args": [
                "ionic",
                "serve",
                "--no-open",
                "--external",
                "--configuration=development",
                "--no-open",
                "--inspect"
            ],
            "problemMatcher": [
                {
                  "pattern": [
                    {
                      "regexp": ".",
                      "file": 1,
                      "line": 1,
                      "column": 1,
                      "message": 1
                    }
                  ],
                  "background": {
                    "activeOnStart": true,
                    "beginsPattern": { "regexp": "." },
                    "endsPattern": { "regexp": "^\\[INFO\\] Development server running!$" }
                  }
                }
            ]
        }
    ]
}

... and then running the following VSCode debug profile:

// launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Edge",
            "type": "msedge",
            "request": "launch",
            "url": "http://localhost:8100",
            "webRoot": "${workspaceFolder}",
            "preLaunchTask": "Start development server"
        },
    ]
}

Naturally, Id rather use the extension which I think could be achieved by adding a new setting for the extension which sets the arguments passed to the ionic serve command. That said, I'm not sure about why the ionic extension debugger stops when the VSCode debugger does not. I actually tried changing the method of authentication to use a popover windows rather then redirect the existing window and even closing the popover window caused the ionic debugger to stop.

Any ideas what sort of changes we need to make to keep the debugger alive?

dtarnawsky commented 5 months ago

This item is being treated as a feature request. The extension generates a dynamic launch.json and tasks.json for debugging and doesn't currently have a way to customize this.