Terminal doesn't flush all line data before firing onExit
See original GitHub issue- VSCode Version: 1.43.0
- OS Version: Windows 10 version 1809
- Does this issue occur on the latest insiders build?: Yes
- Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce:
- Create a
Task
which usesCustomExecution
to output to aPseudoTerminal
and specify one or moreProblemMatcher
s which are relevant to theTask
’s output. - Run the
Task
. Its output seemingly will not be processed by the specifiedProblemMatcher
s. At least, the effects are not applied - I cannot CTRL+click on file names, problems are not reported in the “Problems” tab, etc.
Sample code:
import * as vscode from "vscode";
import { exec } from "child_process";
// Simply run tsc and output the results to the terminal
class MyBuildTaskTerminal implements vscode.Pseudoterminal {
private writeEmitter = new vscode.EventEmitter<string>();
onDidWrite: vscode.Event<string> = this.writeEmitter.event;
private closeEmitter = new vscode.EventEmitter<void>();
onDidClose?: vscode.Event<void> = this.closeEmitter.event;
open(_initialDimensions: vscode.TerminalDimensions | undefined): void {
this.doBuild();
}
close(): void {
}
private async doBuild(): Promise<void> {
this.writeEmitter.fire("Starting build...\r\n");
// non-existent.ts doesn't exist and will output an error, but there will
// be no corresponding entry in the "Problems" tab.
//
// Similarly, if the file did exist but contained errors (and I prefixed the
// command with "cd /path/to/workspace/dir && "), I wouldn't be able
// to CTRL+click the file's path to go to the location of the problem
exec("tsc non-existent.ts", (_error, stdout, stderr) => {
this.writeEmitter.fire(stdout);
this.writeEmitter.fire(stderr);
this.closeEmitter.fire();
});
}
}
const myTask = new vscode.Task(
{ type: "myType" },
vscode.TaskScope.Workspace,
"myTask",
"mySource",
new vscode.CustomExecution(async () => {
// Pseudo-terminal implementing some task which fires onDidWrite()'s emitter
// to output text. For this example, it runs tsc and outputs any compile errors
return new MyBuildTaskTerminal();
}),
"$tsc" // TypeScript errors should be picked up
);
vscode.tasks.executeTask(myTask);
VSCode behaves as expected if I change the line
new vscode.CustomExecution(...)
to
new vscode.ShellExecution("tsc non-existent.ts")
In my actual project, the Task
’s logic is more complex and I can’t simply use ShellExecution
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Why does printf not flush after the call unless a newline is in ...
The stdout stream is line buffered by default, so will only display what's in the buffer after it reaches a newline (or when...
Read more >Chromium Command Line Switches Cheat Sheet - Kapeli
The constant OS_WIN must be defined. /prefetch:# argument shared by all process types that don't have their own. It is likely that the...
Read more >List of Chromium Command Line Switches - Peter Beverloo
List of Chromium Command Line Switches. There are lots of command lines which can be used with the Google Chrome browser. Some change...
Read more >Keyboard Control - mpv.io
For example, before mpv --log-file f.txt would write a log to f.txt, ... any option given on the command line usually affects all...
Read more >Issues closed in the 2.x development cycle - IPython
Just one bugfix: fixed bad CRCRLF line-endings in notebooks on Windows ... #5703: Notebook doesn't render with “ask me every time” cookie setting...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Tyriar I added
setTimeout
hack so that myonLineData
listener isn’t disposed until later, giving “enough” time after whenexit
is fired for the rest of the line data to come through.I modified the task provider sample to make a super simple example:
Task for tasks.json:
When this runs without break points and with some logging, I can see that the the terminal is firing
onExit
before almost all of theonLineData
. @Tyriar I thought there was something in place to prevent this now. How should I recommend folks handle this?