Yes, you can add a preliminary task that will sleep for x seconds.
Suppose you have a client and server on Node.js, and loading the database with the server takes longer, this causes problems with the client.
Client debugger delay on vscode will work the same on Mac OS X
First, create a task in the same folder as the launch.json file named tasks.json, which will create a shell command before launching the client.
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "Sleepdelay", "type": "shell", "command": "sleep 6", "windows": { "command": "ping 127.0.0.1 -n 6 > nul" }, "group": "none", "presentation": { "reveal": "silent", "panel": "new" } } ]
}
Add the following preliminary task to the launch.json file now to invoke the task.
"configurations": [ { "type": "chrome", "request": "launch", "name": "Client", "url": "http://localhost:9090", "webRoot": "${workspaceFolder}/client/src", "breakOnLoad": true, "sourceMapPathOverrides": { "webpack:///./src/*": "${webRoot}/*" }, "preLaunchTask": "Sleepdelay" //"runtimeExecutable": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" }, { "type": "node", "request": "launch", "name": "Server", "program": "${workspaceFolder}/server/server.js", "envFile": "${workspaceFolder}/server/.env", "cwd": "${workspaceFolder}/server/" } ], "compounds": [ { "name": "Server/Client", "configurations": ["Server", "Client"] } ]
The sleep command is available on Linux and MAC OS X. For Windows, just use this hack instead:
ping 127.0.0.1 -n 6> zero
Now you have an easy way to delay starting a client in front of the server.