skip to Main Content

I finally have debugging working on both the client and server for SvelteKit in VS Code. But I can’t figure out how to get both configs to start up with one combined configuration or something similar. I just want to run once in the debugger, it starts up the dev server, attaches to the node.js Vite process on the server side on the first config, then launches chrome and attaches the debugger on the second config.

I can do this manually by starting the server debug config, then select the "Launch Chrome" config, and both debuggers will be running and working, The compounds launch config is almost what I need, but they start in parallel. This doesn’t allow the server to start fast enough and chrome misses attaching to it. I tried different things with tasks, but I could never get the debugger to attach correctly.

Here are my two debug configs:

{
     "type": "node-terminal",
     "name": "Run Script: dev",
     "request": "launch",
     "command": "npm run devv",
     "cwd": "${workspaceFolder}"
},
{
     "name": "Launch Chrome",
     "request": "launch",
     "type": "chrome",
     "url": "http://localhost:5173",
     "port": 5173,
     "smartStep": true,
     "skipFiles": [
          "<node_internals>/**",
          "node_modules/**",
          "/**/*.js",
          "/**/*.css",
          "/*\.js"
     ],
     "userDataDir": "${workspaceFolder}/.vscode/chrome"
}

eg: I can’t figure out how to setup one config, that runs the dev server config and then the launch chrome config sequentially instead of in parallel.

2

Answers


  1. Chosen as BEST ANSWER

    I found the answer to this in another post. The gist is to create a task that just waits x amount of seconds, and use that as your prelaunchtask for the Launch Chrome config. Then create a compound debug config combining the client/server and it doesn't matter if they are then started in parallel. The Launch Chrome config waits, then starts and gives the server enough to time to start.

    I got the answer from this extremely helpful post.


  2. There’s such a thing as Compound launch configurations to specify multiple launch configurations to launch in parallel, but unfortunately for you, it doesn’t support running each launch config in sequential order, which is a bit of a shame, since tasks have a compounding feature that allows for specifying that the tasks should run sequentially.

    See this feature-request issue ticket in the VS Code GitHub repo: Run multiple launch.json test configurations in sequence #71885. You can show your support for the issue ticket by giving a thumbs up reaction to the issue. But please don’t make a "me too" comment. "me too" comments generally come off as annoying to repo maintainers because they clutter up discussion and don’t contribute anything of significant value.

    For your reference / learning purposes, I found the above issue ticket by googling "github vscode issues compound launch config order sequence".

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search