question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

errors in dependsOn background tasks do not prevent subsequent tasks from executing

See original GitHub issue
  • VSCode Version: 1.32.1
  • OS Version: 18309

Steps to Reproduce:

create launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [        
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}\\src\\FrontEnd\\build",
            "preLaunchTask": "core"
        }
    ]
}
  1. create task.json:
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "core",            
            "type": "npm",
            "script": "start",
            "path": "src/FrontEnd/core/",
            "isBackground": true,
            "dependsOn":["loss"],
            "problemMatcher":{
                "owner": "custom",
                "pattern":[
                    {
                        "regexp": "something not exists",
                        "file": 1,
                        "location": 2,
                        "message": 3
                    }
                ],
                "background": {
                    "activeOnStart": true,
                    "beginsPattern": "core@1.0.0 start",
                    "endsPattern": "created ..\\\\build\\\\vendor.js"
                }
            }
        },
        {
            "label": "loss",            
            "type": "npm",
            "script": "watch",
            "path": "src/FrontEnd/loss/",
            "isBackground": true,            
            "problemMatcher":{
                "owner": "custom",
                "pattern":[
                    {
                        "regexp": "something not exists",
                        "file": 1,
                        "location": 2,
                        "message": 3
                    }
                ],
                "background": {
                    "activeOnStart": true,
                    "beginsPattern": "loss@1.0.0 start",
                    "endsPattern": "waiting for changes"
                }
            }
        }
    ]
}

I can use beginsPattern/endsPattern with no issue if I direct launched by preLaunchTask, but if I have DependsOn for same task, it will run the dependencies but can’t detect it’s status by using endsPattern, the task will hang there. it looks like a bug for me.

I tried to use the new Terminal: “terminal.integrated.windowsEnableConpty”: false/true, no difference. I tried to use presentation.panel:“dedicated”, no difference.

I think we have done a nice work on putting tasks running in background and launch, but not those tasks in DependsOn property.

Does this issue occur when all extensions are disabled?: Yes

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:27
  • Comments:24 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
alexr00commented, Jul 24, 2020

@penx thanks for the simple repro repository.

Until now, you could have background tasks in dependsOn, but since those background tasks never “finish”, you couldn’t sequence anything off of them.

I have pushed a small change that does allow some sequencing. You can have background tasks in dependsOn and they can be sequenced. However any errors that those background tasks produce will not prevent subsequent tasks from executing. I will leave this issue open to track supporting that.

9reactions
penxcommented, Jun 5, 2020

I created a basic repo that shows the issue of not being able to create a task that depends on a background/watch task:

https://github.com/penx/vscode-task-dependson

In this project:

  • the launch configuration depends on task ‘Two’ and works fine
  • the task ‘One’ depends on task ‘Two’ and ‘Three’ in sequence, but neither ‘One’ nor ‘Three’ execute

As per @linusbrolin’s comment above, the documentation says that this should work:

Any background/watch tasks used in dependsOn with “dependsOrder”: “sequence” must have a problem matcher that tracks when they are “done”

… so please can you either mark this ticket as a bug or else update the documentation to make it clear this is not supported?

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Node",
      "type": "node",
      "request": "launch",
      "program": "${file}",
      "preLaunchTask": "Two"
    }
  ]
}

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "One",
      "type": "shell",
      "command": "echo start1",
      "dependsOrder": "sequence",
      "dependsOn": ["Two", "Three"],
      "problemMatcher": []
    },
    {
      "label": "Two",
      "type": "shell",
      "isBackground": true,
      "command": "echo start2 && echo end2 && read varname",
      "problemMatcher": {
        "owner": "custom",
        "pattern": {
          "regexp": "^$"
        },
        "background": {
          "activeOnStart": true,
          "beginsPattern": "start2",
          "endsPattern": "end2"
        }
      }
    },
    {
      "label": "Three",
      "type": "shell",
      "command": "echo start3"
    }
  ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

UIApplication Background Task Notes - Apple Developer
The UIApplication background task mechanism allows you to prevent your app from being suspended for short periods of time. While the API involved...
Read more >
Tasks in Visual Studio Code
Any background/watch tasks used in dependsOn with "dependsOrder": "sequence" must have a problem matcher that tracks when they are "done". The following task...
Read more >
Debug a background task - UWP applications - Microsoft Learn
This topic assumes that you already have an existing app with a background task to debug. The following is specific to background tasks...
Read more >
Background Tasks - FastAPI
You can define background tasks to be run after returning a response. This is useful for operations that need to happen after a...
Read more >
iOS background processing - Background App Refresh Task
Performance: ensure background execution does not have any negative effect on active usage. Privacy: Users should be aware of background tasks ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found