Skip to content

Compound tasks are ignoring endsPattern of dependent tasks #85400

@perspectivus1

Description

@perspectivus1

The issue described below seems to be related to issue #83065, but one described below has nothing to do with code-workspace files or with multi-root workspaces.

  • VSCode Version: 1.40.1
  • OS Version: Windows 10.0.17763 Build 17763

Steps to Reproduce

Setup

I created a reference github repo that reproduces this issue. It includes tasks.json and launch.json files: https://github.com/perspectivus1/compound-tasks.

Nevertheless, here they are:

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "compoundtask1",
            "type": "shell",
            "command": "echo Running compoundtask1",
            "dependsOn": ["task1"]
        },
        {
            "label": "compoundtask2",
            "type": "shell",
            "command": "echo Running compoundtask2",
            "dependsOn": ["task2"]
        },
        {
            "label": "task1",
            "type": "shell",
            "command": "echo STARTED task1... && echo WATCHING task1... && echo FINISHED task1... && timeout 10 /nobreak && echo EXITING task1...",
            "isBackground": true,
            "problemMatcher": {
                "pattern": {
					"regexp": ""
				},
                "background": {
                    "activeOnStart": true,
                    "beginsPattern": "STARTED task1",
                    "endsPattern": "FINISHED task1"
                }
            }
        },
        {
            "label": "task2",
            "type": "shell",
            "command": "echo STARTED task2... && echo WATCHING task2... && echo FINISHED task2... && timeout 10 /nobreak && echo EXITING task2...",
            "isBackground": true,
            "problemMatcher": {
                "pattern": {
					"regexp": ""
				},
                "background": {
                    "activeOnStart": true,
                    "beginsPattern": "STARTED subtask2",
                    "endsPattern": "nomatch"
                }
            }
        }
    ]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch w/task1",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/index.js",
            "preLaunchTask": "task1"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch w/task2",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/index.js",
            "preLaunchTask": "task2"
        }
    ]
}

task1 and task2 are both background tasks that simulate a watcher. They both exit after approximately 10 seconds.

task1 has a matching endsPattern; whereas task2 has a non-matching endsPattern.

Launch w/task1 and Launch w/task2 are both launch confiruations, each configured with its respective preLaunchTask.

Observed behavior when debugging the launch configurations

As expected, when debugging Launch w/task1, the application is launched as soon as task1's endsPattern is matched.

As expected, when debugging Launch w/task2, the application is launched only whentask2 exits (since it has no match for its endsPattern).

Observed behavior when running the compound tasks

When running compoundtask1, it doesn't start untils its dependent task1 exits. This is unexpected, since its endsPattern matches 10 seconds before the task exits.

When running compoundtask2, it doesn't start untils its dependent task2 exits. This is expected, since its endsPattern does not match.

Why it matters

Besides being inconsistent, the observed behavior makes it impossible to debug a launch configuration that is dependent on 2 or more background tasks.

The reason is that the only way to do this is to define a launch configuration with a preLaunchTask that references a compound task.

However, as demonstrated above, the compound task runs only when its dependent tasks exit, which means that the launch configuration never starts.

Metadata

Metadata

Assignees

Labels

*duplicateIssue identified as a duplicate of another issue(s)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions