Killing tasks does not actually kill them
Type: Bug
When I kill a task in the terminal tab, it gets removed from the lists of running tasks, however starting in one of the recent code versions (probably 1.98.0?), the task does not get killed and is still runing in the background and can also still be found in the windows task manager.
Example: vite dev/hot server. Everytime I kill a server task, it keeps on running. The next time I start it, the used port number will increase due to the previous one still being in use.
VS Code version: Code 1.98.0 (6609ac3d66f4eade5cf376d1cb76f13985724bcb, 2025-03-04T21:06:18.612Z) OS version: Windows_NT x64 10.0.26100 Modes:
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 x 3192) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on 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 skia_graphite: disabled_off video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | undefined |
| Memory (System) | 47.81GB (33.72GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |
Extensions (14)
| Extension | Author (truncated) | Version |
|---|---|---|
| project-manager | ale | 12.8.0 |
| npm-scripts-advanced | dae | 0.0.8 |
| vscode-eslint | dba | 3.0.10 |
| githistory | don | 0.6.20 |
| gitlens | eam | 16.3.2 |
| EditorConfig | Edi | 0.17.1 |
| prettier-vscode | esb | 11.0.0 |
| i18n-ally | lok | 2.13.1 |
| materialdesignicons-intellisense | luk | 4.1.0 |
| git-graph | mhu | 1.30.0 |
| atom-keybindings | ms- | 3.3.0 |
| errorlens | use | 3.24.0 |
| volar | Vue | 2.2.8 |
| material-theme | zhu | 3.19.0 |
Facing this issue too =(
I can get around it with Ctrl+C in the terminal, but if I forget then the port's left hanging and I'll have to pull out netstat and taskkill...
Edit: Found a faster way to close hanging ports, just run npx kill-port <PORT>. If you have multiple hanging, you can use a wildcard like npx kill-port 808*
@deepak1556 or @Tyriar nothing has changed with tasks in recent iterations that could explain this. Are you aware of any node pty changes or other that could?
Yeah very likely related to https://github.com/microsoft/vscode/issues/242942#issuecomment-2708933985, will check.
Can users share a sample task configuration that repros this issue, tested with the following
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"isBackground": true,
"command": ".\\node_modules\\.bin\\vite.cmd dev",
"problemMatcher": [],
"label": "vite dev",
"detail": "run vite task"
}
]
}
Killing the terminal kills the task without issues.
{
"version": "2.0.0",
"tasks": [
{
"label": "npm: dev",
"type": "npm",
"script": "dev",
// "isBackground": true,
"presentation": {
"panel": "dedicated",
"reveal": "silent"
},
"runOptions": {
"runOn": "folderOpen"
},
"problemMatcher": []
}
]
}
I removed isBackground to see if that was the issue, but the node process continues running either way. I think I had type shell first and then tried the npm way, but I think it was just npm run dev so maybe not all that different from type npm.
Not sure if it related to VSCode directly. But facing this issue from last week. So annoying. All "npm run dev" commands not killing port by clicking ctrl+c On "ExpressJS" (nodemon) and "NestJS" frameworks with hot reload functionality.
We're having trouble reproducing the issue. To help us narrow down what change caused the issue, please run the following command to find the build. It will start previous releases of VS Code insiders to see where the regression was introduced:
npx --yes @vscode/vscode-bisect@latest- follow the instructions until you found the offending build
- report back the commit range in this issue
Thanks!
Can users check if the issue is fixed in latest insiders https://code.visualstudio.com/insiders with "terminal.integrated.windowsUseConptyDll": false setting ?
Version: 1.99.0-insider (user setup) | Version: 1.98.1 (user setup)
Commit: c1fb4c3983bcc28e63dd159dbbb2ea98d352d33e Date: 2025-03-12T08:28:07.410Z Electron: 34.3.2 ElectronBuildId: 11161073 Chromium: 132.0.6834.210 Node.js: 20.18.3 V8: 13.2.152.41-electron.0 OS: Windows_NT x64 10.0.26100
Not fixed.
Steps to reproduce (in my case): npx kill-port 3000 npx kill-port 3001 Run both apps Click kill button. (for both) Run again -> (issue with port)
Tested with and without terminal.integrated.windowsUseConptyDll toggle:
Enabled toggle make ctrl+c faster. But not effect this issue. Problem only with "kill button"
Insider and usual version have same behaviour.
!!! New important info: Ctrl+C working. But button kill - not. This one on screenshot.
Temporary workaround: "Do not click kill button, use ctrl+c"
Results: App cannot launch again using same port. netstat -an | find "3001" TCP 0.0.0.0:3001 0.0.0.0:0 LISTENING TCP [::]:3001 [::]:0 LISTENING npx kill-port 3001 -> resolve issue and allow next start Error in logs: result.txt
@alikil thanks for checking, this was with "terminal.integrated.windowsUseConptyDll": false right ?
Can you provide the results of https://github.com/microsoft/vscode/issues/242891#issuecomment-2715847854, it would help us narrow down the regression.
Same behaviour for me when tasks are killed via command palette task: terminate task -> all running tasks. Tasks are not actually killed.
@capc0 Can you provide the results of https://github.com/microsoft/vscode/issues/242891#issuecomment-2715847854?
I cant reproduce the behaviour within the npx --yes @vscode/vscode-bisect@latest opened versions of vscode.
Link to github after full test. (npx --yes @vscode/vscode-bisect@latest)
https://github.com/microsoft/vscode/compare/1ba0fac10a2b5c6d2656716aa79b0858bd34809c...105d4af21c11ed9f13e65feba4ce4b41217e2024
For me the issue seems fixed in the insiders version. Cant reproduce the bug there at all.
In the normal version it is reproduceable everytime.
Same settings.json, same workspace, same extensions (but different extension verions maybe).
{
"terminal.external.windowsExec": "C:\\Program Files\\Git\\git-bash.exe",
"terminal.integrated.defaultProfile.windows": "Git Bash"
}
Can users confirm if the issue repros with 1.98.2
Yes, I can confirm that the issue still exists
Version: 1.98.2 (user setup)
Commit: ddc367ed5c8936efe395cffeec279b04ffd7db78
Date: 2025-03-12T13:32:45.399Z
Electron: 34.2.0
ElectronBuildId: 11161602
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
OS: Windows_NT x64 10.0.26100
@capc0 thanks for testing, can you share a minimal repro workspace with tasks configured. So far we have not been able to repro the issue.
Additionally, can you capture the logs with following steps
- Run
F1 > Developer: Set Log Leveland chooseTrace - Let the issue repro, that is start a task and kill it confirm that it leaks
- Open the output view and select export logs
@deepak1556 repo is available here https://github.com/capc0/vs-code-issue-242891
npm itask dev(command palette)- wait 5 seconds
task terminal all tasks(command palette)- observe that tasks are still running in task manager
In 1.98.2 I can confirm that the issue still exists with
"terminal.integrated.windowsUseConptyDll": false
or when the line is missing.
When I add
"terminal.integrated.windowsUseConptyDll": true
it is working for me!
can confirm the "tweak" windowsUseConptyDll set to true changes something (1.98.2)
In Settings as preview option shown under
Terminal > Integrated: Windows Use Conpty Dll Preview Whether to use the experimental conpty.dll (vl.22.250204002) shipped with VS Code, instead of the one bundled bundled with Windows
In my case "node" process in windows not closing without setting that option to true if terminal closed without previously aborting terminal with Ctrl + C. If experimental conpty.dll is used terminal properly closing node process when closing without manually aborting process inside the terminal
terminal.integrated.windowsUseConptyDll
Switching on the setting for me fixed the issue, but it looks like the setting is actually somehow improperly linked, like the preview version shouldn't be enabled but is, and the setting being applied in a way that isn't seperated from the default, previous value.
I ran into the same issue lately. I fixed by searching "conpty" in the settings and enabling the "Windows Use Conpty Dll" preview setting. I second what @kilotone said, there are now two settings and the preview one (not enabled by default) is the working one.
Version: 1.98.2 (user setup) Commit: ddc367ed5c8936efe395cffeec279b04ffd7db78 Date: 2025-03-12T13:32:45.399Z Electron: 34.2.0 ElectronBuildId: 11161602 Chromium: 132.0.6834.196 Node.js: 20.18.2 V8: 13.2.152.36-electron.0 OS: Windows_NT x64 10.0.26100
For me working on latest insider version. But with some small issues...
- Working only if both toggles disabled
- When fully close IDE, it not killing port...
- After "ctrl+c" I have to type 'Y' (few times click ctrl+c not stopping...)
Any updates on this issue? Any temporary workarounds? It is really annoying that kill not working (every time need to kill port manually.)
Version: 1.99.0-insider (user setup)
Commit: 90dde06fb64726923ebef8121bd63836529b7d8b
Date: 2025-03-20T07:42:45.872Z
Electron: 34.3.2
ElectronBuildId: 11161073
Chromium: 132.0.6834.210
Node.js: 20.18.3
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100
- When fully close IDE, it not killing port...
tracking that as a feature request here #206607
- After "ctrl+c" I have to type 'Y' (few times click ctrl+c not stopping...)
this is expected if that's a part of your task
Same root cause as #246194. I think we need to enable that setting for stable by default.
I too am experiencing this issue on macOS latest version. If the task is terminated the Vite dev server keeps running in the background occupying the port.
Version: 1.107.0 Commit: 618725e67565b290ba4da6fe2d29f8fa1d4e3622 Date: 2025-12-10T07:43:47.883Z Electron: 39.2.3 ElectronBuildId: 12895514 Chromium: 142.0.7444.175 Node.js: 22.21.1 V8: 14.2.231.21-electron.0 OS: Darwin arm64 25.1.0