Repository navigation
Report problems of pending lines when a task problem collector is done - #346122
Merged
Megan Rogge (meganrogge) merged 2 commits intoNov 13, 2026
Merged
Megan Rogge (meganrogge) merged 2 commits into
Megan Rogge (meganrogge) merged 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Pending file-location lookups can delay cleanup until after task completion, allowing the old collector to delete diagnostics from a subsequent run unless terminal exit paths await finalization.
1 open issue
What changed in this PR
This PR addresses #179361 by delaying task problem-collector finalization until queued output lines finish processing, so background tasks can report diagnostics for the last file even without an end-pattern line.
Changes:
- Defer marker reporting and cleanup until pending line processing settles, including rejection.
- Add a regression test that calls
done()immediately after queuing diagnostics for two files.
| File | Description |
|---|---|
src/vs/workbench/contrib/tasks/test/common/problemCollectors.test.ts |
Tests delivery of all four diagnostics when finalization starts with pending lines. |
src/vs/workbench/contrib/tasks/common/problemCollectors.ts |
Defers final marker reporting and cleanup until the processing queue settles. |
Review effort: Balanced
Lines are fed to a problem collector asynchronously (processLine chains them on a promise), but done() reported and cleaned markers immediately. When a background task exits right after printing its output, done() ran before the queued lines were processed. Markers of the last resource were then recorded but never delivered, because a watching collector only delivers a resource's markers when the resource changes, the end pattern is seen, or done() runs. Only the problems of the first file showed up. Make done() wait for the pending lines before reporting the markers, and return a promise for that. When a background task exits, wait for it before the task is released and its end is signaled, so that the cleanup of this run can't remove markers from a later run of the same task. Fixes microsoft#179361
Oke Iyanuoluwa Enoch (Iyanuoluwa007)
force-pushed
the
tasks-background-flush-on-exit
branch
from
November 5, 2026 17:31
606a68f to
bfe72b1
Compare
The problems of a background task's last lines were lost because the task exits before they are processed. Regular tasks report their markers when the process ends, 100 ms after exit, and don't wait for done(), so making done() asynchronous for them only delayed the report and the cleanup into a possible next run. Keep done() synchronous in AbstractProblemCollector, as before, and only wait for the pending lines in WatchingProblemCollector, which the task system awaits when a background task exits.
|
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Oke Iyanuoluwa Enoch ***@***.***>
Sent: Wednesday, November 4, 2026 4:05:18 PM
To: microsoft/vscode ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [microsoft/vscode] Report problems of pending lines when a task problem collector is done (PR #346122)
Fixes #179361<#179361>
Problem
With the background task from the issue (cat data.txt with a beginsPattern/endsPattern problem matcher), only the problems of the first file show up. The same matcher on a non-background task shows all four.
AbstractProblemCollector.processLine queues each line on a promise chain (this.tail), so lines are processed asynchronously. done() however reported and cleaned the markers immediately. For a background task, terminalTaskSystem calls watchingProblemMatcher.done() synchronously in the terminal's onExit handler. When the process exits right after printing its output (as cat does), the queued lines have not been processed yet at that point:
1. done() reports nothing, because no markers are recorded yet.
2. The queued lines are processed afterwards. The markers of file are delivered when the collector switches to file2.
3. The markers of file2 are recorded, but nothing delivers them any more: a watching collector only delivers a resource's markers when the resource changes, when the end pattern is seen, or in done().
In the issue, End is the last line of data.txt. Without a trailing newline, LineDataEventAddon only emits it when the addon is disposed, which is after the task has stopped listening, so the end pattern is never seen and step 3 applies.
Fix
done() now waits for the pending lines (this.tail) before reporting and cleaning the markers. If no line was ever processed it behaves as before. A rejected line does not prevent the final report.
Testing
Added a unit test to problemCollectors.test.ts that feeds the issue's output (without the end pattern) to a WatchingProblemCollector and calls done() right away, the way the task system does on exit.
* Before the fix it fails: only /file1 (problem1, problem2) is delivered.
* After the fix both /file1 and /file2 are delivered with all four problems.
All tests in src/vs/workbench/contrib/tasks/test/common pass (87 passing, 5 pending as before), and ESLint is clean on the changed files.
________________________________
You can view, comment on, or merge this pull request online at:
#346122
Commit Summary
* 606a68f<606a68f> Report problems of pending lines when a task problem collector is done
File Changes
(2 files<https://github.com/microsoft/vscode/pull/346122/files>)
* M src/vs/workbench/contrib/tasks/common/problemCollectors.ts<https://github.com/microsoft/vscode/pull/346122/files#diff-b219586d80118e6f87be6f44710e4ff2e5d3b52714a1240fec46609bbca090dd> (11)
* M src/vs/workbench/contrib/tasks/test/common/problemCollectors.test.ts<https://github.com/microsoft/vscode/pull/346122/files#diff-238fcf874f94da7bc6e6604fff16f313b69640af59dff5d629685c68199f10bd> (53)
Patch Links:
* https://github.com/microsoft/vscode/pull/346122.patch
* https://github.com/microsoft/vscode/pull/346122.diff
—
Reply to this email directly, view it on GitHub<#346122?email_source=notifications&email_token=CMMPBZF3GRAMY5CB25HRGK35XOKY3A5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF42TCNRRGU4TIMBTHCTHEZLBONXW5KTTOVRHGY3SNFRGKZFFMV3GK3TUVRTG633UMVZF6Y3MNFRWW>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/CMMPBZANQLX33V6ULX7A6ZD5XOKY3AVCNFSNUABEKJSXA33TNF2G64TZHM2DCOBYGE4TAMB3JFZXG5LFHM3DEMJRGM3DGNBUGOQXMAQ>.
You are receiving this because you are subscribed to this thread.
|
Megan Rogge (meganrogge)
enabled auto-merge
November 11, 2026 18:48
Raymond Zhao (rzhao271)
approved these changes
Nov 13, 2026
roblourens
approved these changes
Nov 13, 2026
Megan Rogge (meganrogge)
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #179361
Problem
With the background task from the issue (
cat data.txtwith abeginsPattern/endsPatternproblem matcher), only the problems of the first file show up. The same matcher on a non-background task shows all four.AbstractProblemCollector.processLinequeues each line on a promise chain (this.tail), so lines are processed asynchronously.done()however reported and cleaned the markers immediately. For a background task,terminalTaskSystemcallswatchingProblemMatcher.done()synchronously in the terminal'sonExithandler. When the process exits right after printing its output (ascatdoes), the queued lines have not been processed yet at that point:done()reports nothing, because no markers are recorded yet.fileare delivered when the collector switches tofile2.file2are recorded, but nothing delivers them any more: a watching collector only delivers a resource's markers when the resource changes, when the end pattern is seen, or indone().In the issue,
Endis the last line ofdata.txt. Without a trailing newline,LineDataEventAddononly emits it when the addon is disposed, which is after the task has stopped listening, so the end pattern is never seen and step 3 applies.Fix
WatchingProblemCollector.done()(used for background tasks) now waits for the pending lines (this.tail) before reporting and cleaning the markers, and returns a promise that resolves once it has. If no line was ever processed it behaves as before. A rejected line does not prevent the final report.When a background task exits,
terminalTaskSystemawaitsdone()before it releases the task, disposes the collector and fires the end events. Otherwise a new run of the same task could start while this run's cleanup was still pending, and that cleanup could remove the new run's markers.Regular tasks (
StartStopProblemCollector) are unchanged:done()stays synchronous there, as on main.Testing
Added a unit test to
problemCollectors.test.tsthat feeds the issue's output (without the end pattern) to aWatchingProblemCollectorand awaitsdone()right away, the way the task system does on exit./file1(problem1,problem2) is delivered./file1and/file2are delivered with all four problems by the time the promise fromdone()resolves. Ifdone()doesn't wait for the pending lines, the test fails.The branch is rebased on main. All tests in
src/vs/workbench/contrib/tasks/testpass (103 passing), ESLint is clean on the changed files, andtsc -p srcreports no errors in them.