SPA server doesn't stop when debugging in VS Code is stopped
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
When stopping a ASP.NET Core SPA application after debugging it in VS Code, the SPA server isn't stopped but continues to run in the background.
### Expected Behavior
The SPA should be stopped just like the backend server.
### Steps To Reproduce
1. Create app from template:
```sh
$ mkdir spa-test
$ cd spa-test
$ dotnet new react
$ cd ClientApp
$ npm install
$ code ..
```
2. `.vscode/launch.json`:
```json
{
"version": "0.2.0",
"configurations": [
{
// 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/dotnet/vscode-csharp/blob/main/debugger-launchjson.md.
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/spa-test.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": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
}
]
}
```
3. `.vscode/tasks.json`:
```json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/spa-test.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
```
4. Start debugging.
5. Stop debugging.
To verify that the SPA server is still running, you can try to start it manually and it will complain that the port is in use.
```sh
$ npm start
```
### Exceptions (if any)
_No response_
### .NET Version
6.0.120
### Anything else?
```
.NET SDK (reflecting any global.json):
Version: 6.0.120
Commit: d63b17be66
Runtime Environment:
OS Name: fedora
OS Version: 38
OS Platform: Linux
RID: fedora.38-x64
Base Path: /usr/lib64/dotnet/sdk/6.0.120/
global.json file:
Not found
Host:
Version: 6.0.20
Architecture: x64
Commit: a08d9ce2ca
.NET SDKs installed:
6.0.120 [/usr/lib64/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.20 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.20 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
Download .NET:
https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs:
https://aka.ms/dotnet/runtimes-sdk-info
```
Process hierarchy while debug is running:
```
$ pstree -s 47853
systemd───systemd───code───code───vsdbg-ui───dotnet───npm start───node───node───10*[{node}]
```
Process hierarchy after debugging has stopped:
```
$ pstree -s 47853
systemd───systemd───npm start───node───node───10*[{node}]
```
When running the application with `dotnet run` the SPA server stops immediately.
Contributor guide
Assessment
This issue has not been assessed yet.