-
Notifications
You must be signed in to change notification settings - Fork 32.8k
terminate tasks gracefully and not forcefully on closing VSCode or when using the "kill" (trashcan) button #206607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This issue here is similar to mine but only concerned about the kill button, and not closing VSCode. |
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation. Happy Coding! |
I agree with this. I guess terminate task using SIGKILL which can't be trapped. I need execute some commands to clean the tmp files created by this task |
🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation. Happy Coding! |
Great, I am really glad that it reached the backlog! If I may make a recommendation:
|
This is especially useful for long running tasks - I've ran across it while creating a task that requires specific ports and runs a clean up process on If I stopped the task by clicking trash icon, I found that the process had continued in the background, which meant the required ports were still in use and had to be killed individually using Totally agree with @Mutantpenguin - this should be an explicit setting defined on a task by task basis. |
Please make an option for this to work with SIGBREAK. I need to terminate our build tools, which have SIGBREAK handlers (just like Ctrl-C in the command prompt) clean up the build and write out partially built data. It's been a PITA for me since Terminate just kills the process. |
Hi VSCode team. Is there any updates about this issue? I also met this issue in our VSCode extension. |
This has been an issue for me for the last few months using VS Code, not sure exactly what version it started, but after updating today it got even worse. I'm developing on Windows with NodeJS (Express backend, Angular frontend, running as tasks within VS Code), every time I close the window, close the workspace, kill tasks or restart running tasks it does not free the port (previous to today's update, this only occurred if I closed the window). If I gracefully kill the tasks within the terminal windows manually ( I've been blindly killing Node processes within Task Manager when this happens, but after today's update I got annoyed and wrote a little PowerShell script (and an accompanying VS Code task!) to automate this process. Hopefully this is resolved eventually, but until then here's the script/task I'm using: PowerShell Script: Param(
[int] $PortNumber,
[ValidateSet("TCP", "UDP", IgnoreCase = $true)]
[string] $Protocol = "TCP"
)
$Protocol = $Protocol.ToUpper()
$processId = $null
if ($Protocol -eq "TCP") {
try {
$connections = Get-NetTCPConnection -LocalPort $PortNumber -ErrorAction SilentlyContinue
if ($connections -is [System.Collections.IEnumerable]) {
$processId = $connections[0].OwningProcess
}
else {
$processId = $connections.OwningProcess
}
}
catch {
# Ignore error if no process is using the port
}
}
elseif ($Protocol -eq "UDP") {
try {
$connections = Get-NetUDPEndpoint -LocalPort $PortNumber -ErrorAction SilentlyContinue
if ($connections -is [System.Collections.IEnumerable]) {
$processId = $connections[0].OwningProcess
}
else {
$processId = $connections.OwningProcess
}
}
catch {
# Ignore error if no process is using the port
}
}
if ($null -eq $processId) {
Write-Host "No process is using $Protocol port $PortNumber"
return
}
$process = Get-Process -Id $processId
Write-Host "Killing $($process.ProcessName) process (PID: ${processId}) using ${Protocol} port ${PortNumber}..."
taskkill /F /PID $processId And then you can run this easily within VS Code by creating a task. This task assumes the above script is saved as {
"version": "2.0.0",
"tasks": [
// Other tasks...
{
"label": "free-port",
"detail": "Free up a port that is currently in use.",
"type": "shell",
"command": "./Stop-ProcessUsingPort.ps1 -Protocol ${input:protocol} -PortNumber ${input:portNumber}",
"options": {
"cwd": "C:\\temp"
},
"problemMatcher": [],
"presentation": {
"close": false
},
"icon": {
"id": "debug-disconnect",
"color": "terminal.ansiRed"
}
}
],
"inputs": [
// Other inputs...
{
"id": "protocol",
"type": "pickString",
"description": "Select the protocol the port is using",
"default": "TCP",
"options": [
{
"value": "TCP",
"label": "Transmission Control Protocol"
},
{
"value": "UDP",
"label": "User Datagram Protocol"
}
]
},
{
"id": "portNumber",
"type": "promptString",
"description": "Enter the port number to free",
"default": "3002"
}
]
}
|
I'm thinking this opt-in setting should apply not only to tasks, but also terminals. |
commit 26e15ec Merge: 0d469ab 69f7abe Author: Johnson Chu <[email protected]> Date: Sat May 17 06:08:15 2025 +0800 Merge branch 'pr/171547' into volar-html commit 0d469ab Merge: beb827e 62c6b33 Author: Johnson Chu <[email protected]> Date: Sat May 17 06:05:53 2025 +0800 Merge branch 'main' into volar-html commit 69f7abe Author: Johnson Chu <[email protected]> Date: Sat May 17 06:02:46 2025 +0800 Resolve merge error for microsoft#169117 commit 62c6b33 Merge: 1c51133 9ffcdae Author: Osvaldo Ortega <[email protected]> Date: Fri May 16 14:32:42 2025 -0700 Merge pull request microsoft#249125 from microsoft/osortega/fix-undefined-tree Fix for undefined tree commit 1c51133 Author: Megan Rogge <[email protected]> Date: Fri May 16 14:30:34 2025 -0700 Ensure tab doesn't get stuck in tool confirmation code block (microsoft#249138) commit 2225332 Author: Michael Lively <[email protected]> Date: Fri May 16 13:13:32 2025 -0700 Always reveal pre-execution & default fallback logic (microsoft#249136) always reveal pre-execution & default fallback logic commit 43611d8 Author: Logan Ramos <[email protected]> Date: Fri May 16 12:49:47 2025 -0700 Ensure widget is hidden prior to action runs (microsoft#249129) commit 2311e6c Author: Sandeep Somavarapu <[email protected]> Date: Fri May 16 21:48:30 2025 +0200 support remote only mcp servers (microsoft#249124) commit ec2bc27 Author: Justin Chen <[email protected]> Date: Fri May 16 12:09:50 2025 -0700 simple browser fix for livepreview and navigation (microsoft#249051) * simple browser fix for livepreview and navigation * better handling of page change commit 3b33503 Author: Michael Lively <[email protected]> Date: Fri May 16 11:55:09 2025 -0700 Bring back container focus for autoreveal cell execution w/ AI (microsoft#249121) bring back container focus. useful for visual indication of "what is going on" commit 9ffcdae Author: Osvaldo Ortega <[email protected]> Date: Fri May 16 11:47:41 2025 -0700 Fix for undefined tree commit 83a0539 Author: Joyce Er <[email protected]> Date: Fri May 16 11:19:00 2025 -0700 fix: set content reference description on historical chat attachments (microsoft#249112) commit 2bcc698 Author: Tyler James Leonhardt <[email protected]> Date: Fri May 16 10:49:13 2025 -0700 Initial support of OAuth in MCP (microsoft#249056) This hooks up everything auth-y to MCP. It's basically implemented by following what we do in Auth land for extensions and doing that again for MCP servers... so it's a lot of code, but it's logic is the same for extensions for the most part. The MCP side of things... this follows the spec: https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization To discover the server metadata needed to get a token to add to MCP requests. This works by leveraging the new Auth issuers API and mapping issuers to auth providers. What will come in the next PR is dynamic creation of an auth provider based on this server information. commit 2d6afdd Author: Sandeep Somavarapu <[email protected]> Date: Fri May 16 17:55:51 2025 +0200 fix the query result (microsoft#249107) commit 857f21b Author: Johannes Rieken <[email protected]> Date: Fri May 16 17:09:32 2025 +0200 Adjust chat editing UX (microsoft#249105) * when invoking agents, allow the IPC protocol to send multiple response chunks in one message prep for microsoft#249083 * make `TextEdit#asEditOperation` aware of the type of edits maybe related to https://github.com/microsoft/vscode-copilot/issues/16964 * `IStreamingEdits` should atomically know if edits are the last set of edits re microsoft#249083 * add `IModifiedFileEntry#waitsForLastEdits` and derive auto-save- and squiggle-block from that commit cd25be0 Author: Ladislau Szomoru <[email protected]> Date: Fri May 16 15:08:29 2025 +0000 SCM - switch quick diff to use the `advanced` diff algo to fix some edge cases (microsoft#249106) commit ab11a1c Author: Sandeep Somavarapu <[email protected]> Date: Fri May 16 16:44:57 2025 +0200 use mcp server codicon (microsoft#249103) commit b76b9cb Author: Benjamin Pasero <[email protected]> Date: Fri May 16 16:44:02 2025 +0200 aux window - scoped services alignments (microsoft#249095) commit bb2641d Author: Benjamin Pasero <[email protected]> Date: Fri May 16 16:43:45 2025 +0200 Update action titles for compact and always on top window modes (microsoft#249100) commit d1c7e48 Author: Benjamin Pasero <[email protected]> Date: Fri May 16 16:43:28 2025 +0200 chat - defer revealing of chat view to after sign-in dialog (microsoft#249102) commit d31ea9d Merge: 3df9f97 5fb999a Author: Lee Murray <[email protected]> Date: Fri May 16 15:21:39 2025 +0100 Merge pull request microsoft#249101 from microsoft/confused-eagle-blush Update codicon font file to reflect recent changes - mcp fix commit 5fb999a Author: lemurra_microsoft <[email protected]> Date: Fri May 16 15:02:06 2025 +0100 Update codicon font file to reflect recent changes - mcp fix commit 3df9f97 Merge: b4451e9 fab0636 Author: Lee Murray <[email protected]> Date: Fri May 16 14:35:05 2025 +0100 Merge pull request microsoft#249093 from microsoft/cruel-wren-maroon Add 'mcp' icon to codicons library commit fab0636 Merge: 2b53e0e b4451e9 Author: Lee Murray <[email protected]> Date: Fri May 16 14:16:44 2025 +0100 Merge branch 'main' into cruel-wren-maroon commit 2b53e0e Author: lemurra_microsoft <[email protected]> Date: Fri May 16 12:18:55 2025 +0100 Add 'mcp' icon to codicons library commit b4451e9 Author: Ladislau Szomoru <[email protected]> Date: Fri May 16 10:43:20 2025 +0000 SCM - polish history item context picker (microsoft#249088) * Saving my work * Tweak picker commit 84fb005 Author: Ladislau Szomoru <[email protected]> Date: Fri May 16 09:54:40 2025 +0000 Git - do not add ellipsis to history item subject/timeline item label (microsoft#249086) commit 548a600 Author: Sandeep Somavarapu <[email protected]> Date: Fri May 16 11:47:31 2025 +0200 fix microsoft#248836 (microsoft#249085) commit 5a708e2 Author: Ladislau Szomoru <[email protected]> Date: Fri May 16 08:36:55 2025 +0000 SCM Graph - do not show inline action in the context menu (microsoft#249075) commit 7369e94 Author: Benjamin Pasero <[email protected]> Date: Fri May 16 10:22:27 2025 +0200 aux window - improve compact actions functionality (microsoft#249070) commit daab3ff Author: Ladislau Szomoru <[email protected]> Date: Fri May 16 08:09:12 2025 +0000 SCM - add the capability to attach a history item as chat context (microsoft#249073) * Saving my work * Got the variable widget working * Refactored the variable widget * Clean up the attachment widget * Content provider stub * Add proposed API for chat context * Add method to get the complete details of a commit commit 7052ebf Author: Johannes Rieken <[email protected]> Date: Fri May 16 10:03:47 2025 +0200 fixes https://github.com/microsoft/vscode-copilot/issues/17264 (microsoft#249072) commit 0ef598f Author: Rob Lourens <[email protected]> Date: Thu May 15 16:36:04 2025 -0700 Don't throw out of tools extension point (microsoft#249057) And use extension.collector.error commit 70d151e Author: Michael Lively <[email protected]> Date: Thu May 15 16:24:50 2025 -0700 Enhance autoReveal arg behavior for AI cell execution tracking (microsoft#248863) * feat - nb executionFollower * actions to enable/disable follower from toolbar * private smart reveal settings * rm executionFollower, overhaul autoReveal behavior if test settings * rm contrib import * undefined checks to avoid failing on 0 commit 75887be Author: Logan Ramos <[email protected]> Date: Thu May 15 15:43:37 2025 -0700 Have empty category up top not down at the bottom (microsoft#249055) commit 13ee3eb Author: Joyce Er <[email protected]> Date: Thu May 15 15:35:49 2025 -0700 fix: register widgets in chat attachments content part (microsoft#249054) commit 1a999e7 Author: Logan Ramos <[email protected]> Date: Thu May 15 15:35:20 2025 -0700 Don't allow element to be undefined when setting aria label (microsoft#249052) Fix microsoft#248832 commit 0dc8ca4 Author: Megan Rogge <[email protected]> Date: Thu May 15 14:28:36 2025 -0700 handle some task disposables (microsoft#249047) fixes microsoft#249002 commit d605617 Merge: 0e566b9 b0d44b7 Author: Osvaldo Ortega <[email protected]> Date: Thu May 15 12:58:51 2025 -0700 Merge pull request microsoft#249043 from microsoft/osortega/fix-auto-search-on-empty Fix for auto search on empty commit b0d44b7 Author: Osvaldo Ortega <[email protected]> Date: Thu May 15 10:56:47 2025 -0700 Fix for auto search on empty commit 0e566b9 Author: Megan Rogge <[email protected]> Date: Thu May 15 10:30:31 2025 -0700 add opt-in setting to gracefully kill terminal processes (microsoft#248947) fix microsoft#206607 commit 17d1fa2 Author: Peng Lyu <[email protected]> Date: Thu May 15 09:11:46 2025 -0700 Re microsoft#249001. Set semanticSearchBehavior to manual (microsoft#249035) Set semanticSearchBehavior to manual commit 7ef9cdd Merge: 0a135e9 300ecf7 Author: Matt Bierner <[email protected]> Date: Thu May 15 08:50:54 2025 -0700 Merge pull request microsoft#248181 from gabritto/hoverlimit [typescript-language-features] Add configuration for maximum hover length commit 300ecf7 Merge: da8633b 0a135e9 Author: Matt Bierner <[email protected]> Date: Thu May 15 08:31:59 2025 -0700 Merge branch 'main' into hoverlimit commit 0a135e9 Author: Sandeep Somavarapu <[email protected]> Date: Thu May 15 16:57:20 2025 +0200 when auto update is set to only enabled extensions then disable auto update only for user disabled extensions (microsoft#249025) commit 5b99231 Author: Benjamin Pasero <[email protected]> Date: Thu May 15 16:36:12 2025 +0200 chat - focus input when clicking into welcome text (microsoft#249028) This helps to make the chat active when shown as editor or into a floating window. commit f6b5642 Author: Benjamin Pasero <[email protected]> Date: Thu May 15 16:06:38 2025 +0200 :lipstick: more types (microsoft#249026) commit 5e964f6 Author: Ladislau Szomoru <[email protected]> Date: Thu May 15 13:40:43 2025 +0000 SCM - add history item resolver for the multi-file diff editor (microsoft#249021) commit 631a3a2 Author: Sandeep Somavarapu <[email protected]> Date: Thu May 15 15:06:55 2025 +0200 fix querying installed mcp servers (microsoft#249010) commit 49fd851 Author: Sandeep Somavarapu <[email protected]> Date: Thu May 15 15:06:27 2025 +0200 fix hiding icon when small (microsoft#249011) commit 0e50aa0 Author: Sandeep Somavarapu <[email protected]> Date: Thu May 15 12:36:42 2025 +0200 show mcp server icon as default icon (microsoft#249009) commit d5b9037 Author: Benjamin Pasero <[email protected]> Date: Thu May 15 12:17:08 2025 +0200 chat - increase login dialog width (microsoft#249008) commit be257d8 Author: Benjamin Pasero <[email protected]> Date: Thu May 15 12:16:13 2025 +0200 notifications - remove unused events (microsoft#249007) commit 43996d7 Author: Randy Lai <[email protected]> Date: Thu May 15 03:04:36 2025 -0700 Update upstream repo for R syntax (microsoft#248880) * Update upstream repo for R syntax * Update cgmanifest and grammar --------- Co-authored-by: Alex Ross <[email protected]> commit 1085eb3 Author: Benjamin Christopher Simmonds <[email protected]> Date: Thu May 15 11:42:34 2025 +0200 Fix gutter indicator direction on first line (microsoft#249006) gutter indicator shows in wrong direction when on first line commit 8e36368 Author: Sandeep Somavarapu <[email protected]> Date: Thu May 15 10:41:37 2025 +0200 use gallery enablement instead of checking setting (microsoft#248998) commit 3919784 Author: Benjamin Pasero <[email protected]> Date: Thu May 15 10:17:03 2025 +0200 chat - go through setup dialog when signed out from status bar (microsoft#248997) commit d02e8e0 Author: Benjamin Pasero <[email protected]> Date: Thu May 15 10:10:42 2025 +0200 chat - enable alternate login provider only when provided (microsoft#248994) commit 17e5ef4 Author: Sandeep Somavarapu <[email protected]> Date: Thu May 15 10:03:10 2025 +0200 fix setting env values with variables (microsoft#248995) commit 12e14b1 Author: Benjamin Pasero <[email protected]> Date: Thu May 15 10:01:17 2025 +0200 dialogs - tweak settings description (microsoft#248993) commit 56e7997 Author: Aiday Marlen Kyzy <[email protected]> Date: Thu May 15 10:00:23 2025 +0200 Taking into account view data when getting line height (microsoft#248712) * wip * wip * using position commit b2feb82 Author: Johannes Rieken <[email protected]> Date: Thu May 15 09:49:16 2025 +0200 ignore prompt-lang for inline chat hint (microsoft#248991) commit 6947b69 Author: Robo <[email protected]> Date: Thu May 15 12:10:32 2025 +0900 fix: revert remote libcxx requirement to 3.4.25 (microsoft#248976) * fix: revert libcxx requirement to 3.4.25 * ci: temp debugging * fix: use gcc 8.5.0 for remote * ci: update cache * ci: fix sysroot directory * ci: fix objdump directory commit 2cf7120 Merge: 88010a2 f534790 Author: Matt Bierner <[email protected]> Date: Wed May 14 18:28:25 2025 -0700 Merge pull request microsoft#248967 from mjbvz/silky-hare Show line range in github uri references commit 88010a2 Author: Aaron Munger <[email protected]> Date: Wed May 14 16:53:57 2025 -0700 render file widgets within tool confirmation messages (microsoft#248964) * render file widgets within tool confirmation messages * de-duplication commit 1f5b32e Merge: 85aa15d 4ce7e38 Author: Osvaldo Ortega <[email protected]> Date: Wed May 14 16:51:51 2025 -0700 Merge pull request microsoft#248966 from microsoft/osortega/fix-search-event-overload Fix for search event overload commit f534790 Author: Matt Bierner <[email protected]> Date: Wed May 14 16:47:29 2025 -0700 Show line range in github uri references commit 4ce7e38 Author: Osvaldo Ortega <[email protected]> Date: Wed May 14 16:36:22 2025 -0700 Fix for search event overload commit 85aa15d Merge: 5fd9fdb 8020c38 Author: Matt Bierner <[email protected]> Date: Wed May 14 15:08:31 2025 -0700 Merge pull request microsoft#248951 from mjbvz/continuing-coyote Add title and clear button to chat history quick pick commit 5fd9fdb Merge: 6e6de65 71888c9 Author: Osvaldo Ortega <[email protected]> Date: Wed May 14 15:02:56 2025 -0700 Merge pull request microsoft#248958 from microsoft/osortega/keyword-suggestions-core-setting Keyword suggestions core setting commit 6e6de65 Author: Sandeep Somavarapu <[email protected]> Date: Wed May 14 23:18:37 2025 +0200 enhance browsing mcp gallery (microsoft#248956) * enhance browsing mcp gallery * use package registry_name commit 71888c9 Author: Osvaldo Ortega <[email protected]> Date: Wed May 14 14:04:48 2025 -0700 Keyword suggestions core setting commit 33cdf6a Merge: 86efdcd 90f38e0 Author: Matt Bierner <[email protected]> Date: Wed May 14 14:02:55 2025 -0700 Merge pull request microsoft#248953 from mjbvz/cuddly-mule Allow passing in extension to marked when rendering markdown commit 86efdcd Author: Tyler James Leonhardt <[email protected]> Date: Wed May 14 14:02:15 2025 -0700 Introduce Issuer handling in the Authentication stack (microsoft#248948) Mostly plumbing... this enables: ``` vscode.authentication.getSession('microsoft', scopes, { issuer: "https://login.microsoftonline.com/common/v2.0" }); ``` And the respective API for an auth providers to handle it being passed in. This props up work in MCP land which needs a way to map an issuer to an auth provider... but I certainly see utility outside of that space. Fixes microsoft#248775 (comment) commit 90f38e0 Author: Matt Bierner <[email protected]> Date: Wed May 14 13:03:11 2025 -0700 Allow passing in extension to marked when rendering markdown This lets you pass in normal marked extensions to customize rendering commit 8020c38 Author: Matt Bierner <[email protected]> Date: Wed May 14 11:35:24 2025 -0700 Add title and clear button to chat history quick pick commit da8633b Merge: 3b6f73a f27a361 Author: Gabriela Araujo Britto <[email protected]> Date: Thu May 8 08:18:56 2025 -0700 Merge branch 'main' into hoverlimit commit 3b6f73a Merge: be96695 977af64 Author: Gabriela Araujo Britto <[email protected]> Date: Wed May 7 11:35:35 2025 -0700 Merge branch 'main' into hoverlimit commit be96695 Author: Gabriela Araujo Britto <[email protected]> Date: Wed May 7 11:34:40 2025 -0700 fix setting name commit 56e2f3c Author: Gabriela Araujo Britto <[email protected]> Date: Wed May 7 11:31:47 2025 -0700 refactor config path commit c2822f8 Merge: 7a1d501 8b03b47 Author: Gabriela Araujo Britto <[email protected]> Date: Mon May 5 14:45:30 2025 -0700 Merge branch 'microsoft:main' into hoverlimit commit 7a1d501 Author: Gabriela Araujo Britto <[email protected]> Date: Mon May 5 13:57:09 2025 -0700 add maximum hover length
Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce:
I am not able to create a real minimal example, but will show my exact usecase here and try to explain it.
bench start
from frappe bench (https://github.com/frappe/bench) and run itbench start
got terminated, but all the processes it itself spawned are still runningPressing CTRL-C instead in the tasks terminal gracefully shuts it down and
bench start
is able to do its proper teardown of all the spawned processes. I am not invested at all inbench
so can't answer specific questions to it, but I know that it is usinghoncho
and a Procfile to managing all these processes.So I guess all I am asking for is a way for tasks to not be forcefully killed, but do the same as CTRL-C in the console would do to it.
This seems to describe that the same functionality already exists for
launch.json
: microsoft/vscode-js-debug#630 (comment)The text was updated successfully, but these errors were encountered: