Skip to content

Fix empty command tasks not terminating by improving _isTaskEmpty logic #251115

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 10, 2025

Tasks with empty command strings ("command": "") were not terminating properly, causing them to run indefinitely with a progress indicator that never completed.

Root Cause

The _isTaskEmpty() method in TerminalTaskSystem was checking (task.command.name !== undefined) but not validating if the command was actually meaningful. Empty string commands were considered "not empty" because "" !== undefined is true, causing them to be processed as valid tasks that attempt terminal execution.

Fix

Modified _isTaskEmpty() to use CommandString.value() and check for non-empty trimmed content:

private _isTaskEmpty(task: CustomTask | ContributedTask): boolean {
    const isCustomExecution = (task.command.runtime === RuntimeType.CustomExecution);
    const hasValidCommandName = task.command.name !== undefined && CommandString.value(task.command.name).trim() !== '';
    return !((task.command !== undefined) && task.command.runtime && (isCustomExecution || hasValidCommandName));
}

Behavior After Fix

Empty command tasks now:

  • Are correctly identified as empty tasks
  • Fire TaskEventKind.End event immediately
  • Return Promise.resolve({ exitCode: 0 }) without starting a terminal process
  • Show as completed successfully in the VS Code UI

Test Case

This configuration from the original issue now works correctly:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Do Nothing in WSL",
            "command": "",
            "runOptions": {
                "runOn": "folderOpen"
            }
        }
    ]
}

The task terminates immediately instead of hanging indefinitely.

Fixes #173842.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • electronjs.org
    • Triggering command: node-gyp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits June 10, 2025 16:35
Co-authored-by: anthonykim1 <62267334+anthonykim1@users.noreply.github.com>
Co-authored-by: anthonykim1 <62267334+anthonykim1@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Task with empty command does not terminate Fix empty command tasks not terminating by improving _isTaskEmpty logic Jun 10, 2025
@Copilot Copilot AI requested a review from anthonykim1 June 10, 2025 16:42
Copilot finished work on behalf of anthonykim1 June 10, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task with empty command does not terminate
2 participants