Skip to content

"Test Results" Panel occasionally displays a phantom terminal #189755

@hsfzxjy

Description

@hsfzxjy

Type: Bug

Version: 1.81.0
Commit: 6445d93
Date: 2023-08-02T12:36:11.334Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 5.15.0-76-generic

2023-08-06.18-41-06.mp4

Steps to Reproduce:

  1. Clear the "Test Results" Panel
  2. Execute command "Test: Run Tests in Current File" very quickly for several times
  3. The "Test Results" Panel now displays two terminals, with the top one acting like phantom, and the bottom one displaying the real messages.

After some investigation, I found the culprit to be that TestResultsViewContent.reveal is not concurrently safe.

public async reveal(opts: { subject: InspectSubject; preserveFocus: boolean }) {
this.didReveal.fire(opts);
await Promise.all(this.contentProviders.map(p => p.update(opts.subject)));
}

Under certain cases, multiple calls to reveal() may happen concurrently within a short time period, which further leads to concurrent calls to TerminalMessagePeek.update, in which multiple instances of terminal are created and attached to the panel.

https://github.com/microsoft/vscode/blob/6445d93c81ebe42c4cbd7a60712e0b17d9463e97/src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts#L1292-1324


This bug was largely improved by commit 360b462 introduced by #189441 , which changed TestResultsViewContent.reveal into

public async reveal(opts: { subject: InspectSubject; preserveFocus: boolean }) {
this.didReveal.fire(opts);
if (!this.current || !equalsSubject(this.current, opts.subject)) {
this.current = opts.subject;
await Promise.all(this.contentProviders.map(p => p.update(opts.subject)));
}
}

This change reduces the possibility of concurrently calling .update() to some extent and thus this bug may be harder to reproduce in the latest main branch. That being said, there's still a chance for this to happen. To thoroughly eliminate the risk, I fix it in PR #189756 .

Metadata

Metadata

Assignees

Labels

insiders-releasedPatch has been released in VS Code Insiders

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions