Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reveal in Sidebar crashes #82290

Closed
OmarTawfik opened this issue Oct 10, 2019 · 22 comments · Fixed by #82881
Closed

Reveal in Sidebar crashes #82290

OmarTawfik opened this issue Oct 10, 2019 · 22 comments · Fixed by #82881
Assignees
Labels
file-explorer Explorer widget issues
Milestone

Comments

@OmarTawfik
Copy link

  • VSCode Version: 1.39
  • OS Version: Darwin x64 18.7.0

This doesn't happen consistently, but every once in a while, this feature would completely crash and I'd have to restart my editor. The steps are as follows:

  • I open a folder, I start editing some code.
  • I right click the tab name, and click Reveal in Sidebar.
  • The whole File explorer is highlighted in blue, without my file actually getting highlighted.

I checked the dev tools, and here is the error that gets shown:

  ERR TreeError [FileExplorer] Data tree node not found: [object Object]: Error: TreeError [FileExplorer] Data tree node not found: [object Object]
    at WorkbenchAsyncDataTree.getDataNode (file:///Applications/VS Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:64272:23)
    at WorkbenchAsyncDataTree.reveal (file:///Applications/VS Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:64253:35)
    at ExplorerView.onSelectResource (file:///Applications/VS Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:292485:31)

I traced it down to this line:

throw new TreeError(this.user, `Data tree node not found: ${element}`);

Which indiates that tree items are refreshed/updated somehow, but the key used to look up this map is still referring to the old object? Should this map be indexed by something else? item id (string)?

@vscodebot
Copy link

vscodebot bot commented Oct 10, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@OmarTawfik
Copy link
Author

OmarTawfik commented Oct 10, 2019

^ these seem unrelated/already closed before that release.

cc @joaomoreno

@isidorn
Copy link
Contributor

isidorn commented Oct 11, 2019

@OmarTawfik first of all thanks for nice description.
If we get more precise steps that would be great since we are tracking this issue down quite some time.
This is not a regression, thus I will assign this to next milestone October to look into the fix.

fyi @joaomoreno for ideas on what additional data we might need here

@isidorn isidorn added this to the October 2019 milestone Oct 11, 2019
@OmarTawfik
Copy link
Author

@isidorn I couldn't get exact repro steps :( this happens randomly every once in a while, and the only remedy I have is to reload VSCode.
Not sure it is a regression or not. It has been there for many weeks.

@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Oct 14, 2019
@isidorn isidorn added the file-explorer Explorer widget issues label Oct 14, 2019
@isidorn
Copy link
Contributor

isidorn commented Oct 18, 2019

Let me know if you find better repro steps!

@isidorn isidorn removed this from the October 2019 milestone Oct 18, 2019
@solomatov
Copy link
Contributor

Does anybody working on it? I want to investigate it.

@solomatov
Copy link
Contributor

solomatov commented Oct 18, 2019

I reproduced it (though it requires some code instrumentation to make the race condition occur more often):

  • You need a folder which is deep enough in the workspace with at least two files. Split the editor open one editor in one half, the other in the other half.
  • Create the following script in the root directory:
while [ 1 ]
do
  touch a.txt
  sleep 0.2
  rm a.txt
  echo 'tick'
done

Create the following function in the following file: vscode/src/vs/workbench/contrib/files/browser/views/explorerView.ts

async function wait(): Promise<void> {
	return new Promise((resolve, reject) => {
		setTimeout(() => resolve(), 500);
	});
}

And add its call to the following place:

	private async onSelectResource(resource: URI | undefined, reveal = this.autoReveal): Promise<void> {
		if (!resource || !this.isBodyVisible()) {
			return;
		}

		// Expand all stats in the parent chain.
		let item: ExplorerItem | undefined = this.explorerService.roots.filter(i => isEqualOrParent(resource, i.resource))
			// Take the root that is the closest to the stat #72299
			.sort((first, second) => second.resource.path.length - first.resource.path.length)[0];

		while (item && item.resource.toString() !== resource.toString()) {
			await this.tree.expand(item);
			await wait(); <<< HERE
			item = first(values(item.children), i => isEqualOrParent(resource, i.resource));
		}

		if (item && item.parent) {
			if (reveal) {
				this.tree.reveal(item, 0.5);
			}

			this.tree.setFocus([item]);
			this.tree.setSelection([item]);
		} else {
			console.log();
		}
	}

Run the script. Then quickly switch between editors left and right. You will have the console full of these errors in a minute or two.

  ERR TreeError [FileExplorer] Data tree node not found: [object Object]: Error: TreeError [FileExplorer] Data tree node not found: [object Object]
    at WorkbenchAsyncDataTree.getDataNode (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:418:23)
    at WorkbenchAsyncDataTree.reveal (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:399:35)
    at ExplorerView.onSelectResource (file:///Users/solomatov/vscode/out/vs/workbench/contrib/files/browser/views/explorerView.js:415:31)
log.ts:196
  ERR TreeError [FileExplorer] Data tree node not found: [object Object]: Error: TreeError [FileExplorer] Data tree node not found: [object Object]
    at WorkbenchAsyncDataTree.getDataNode (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:418:23)
    at WorkbenchAsyncDataTree.expand (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:324:31)
    at ExplorerView.onSelectResource (file:///Users/solomatov/vscode/out/vs/workbench/contrib/files/browser/views/explorerView.js:409:33)
log.ts:196
  ERR TreeError [FileExplorer] Data tree node not found: [object Object]: Error: TreeError [FileExplorer] Data tree node not found: [object Object]
    at WorkbenchAsyncDataTree.getDataNode (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:418:23)
    at WorkbenchAsyncDataTree.reveal (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:399:35)
    at ExplorerView.onSelectResource (file:///Users/solomatov/vscode/out/vs/workbench/contrib/files/browser/views/explorerView.js:415:31)
log.ts:196
  ERR TreeError [FileExplorer] Data tree node not found: [object Object]: Error: TreeError [FileExplorer] Data tree node not found: [object Object]
    at WorkbenchAsyncDataTree.getDataNode (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:418:23)
    at WorkbenchAsyncDataTree.expand (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:324:31)
    at ExplorerView.onSelectResource (file:///Users/solomatov/vscode/out/vs/workbench/contrib/files/browser/views/explorerView.js:409:33)
log.ts:196
  ERR TreeError [FileExplorer] Data tree node not found: [object Object]: Error: TreeError [FileExplorer] Data tree node not found: [object Object]
    at WorkbenchAsyncDataTree.getDataNode (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:418:23)
    at WorkbenchAsyncDataTree.expand (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:324:31)
    at ExplorerView.onSelectResource (file:///Users/solomatov/vscode/out/vs/workbench/contrib/files/browser/views/explorerView.js:409:33)
log.ts:196
  ERR TreeError [FileExplorer] Data tree node not found: [object Object]: Error: TreeError [FileExplorer] Data tree node not found: [object Object]
    at WorkbenchAsyncDataTree.getDataNode (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:418:23)
    at WorkbenchAsyncDataTree.reveal (file:///Users/solomatov/vscode/out/vs/base/browser/ui/tree/asyncDataTree.js:399:35)
    at ExplorerView.onSelectResource (file:///Users/solomatov/vscode/out/vs/workbench/contrib/files/browser/views/explorerView.js:415:31)

@solomatov
Copy link
Contributor

solomatov commented Oct 19, 2019

My thoughts on how to resolve it:

  • We need to check whether item we are sent is valid or not
  • What to do if it's not? The first idea is to retry, but might it live to livelocks? I.e. if a user uses remote extension over a sketchy connection?

@solomatov
Copy link
Contributor

Also, notice that there're two places where exception arises. It happens both in reveal and expand.

@solomatov
Copy link
Contributor

I reread the description, and it seems that I don't have the tree highlighted in blue. Though, I used the master version for the fix.

@solomatov
Copy link
Contributor

Checked, the tree is functional after such an exception.

@joaomoreno
Copy link
Member

Cool. But @isidorn, this doesn't seem to nail the exact issue reported by the user since it was originally reported that:

This doesn't happen consistently, but every once in a while, this feature would completely crash and I'd have to restart my editor.

@solomatov
Copy link
Contributor

solomatov commented Oct 21, 2019

@joaomoreno @isidorn I fixed it on the master version, so it might have been alleviated by some fixes.

Also, we have our internal users reporting an issue, when the item isn't selected even though, the editor is switched which seems to be very similar to what the PR fixes. I talked to @OmarTawfik about this and it seems that the original issue might be the same as that one.

@isidorn isidorn added this to the October 2019 milestone Oct 23, 2019
@isidorn
Copy link
Contributor

isidorn commented Oct 23, 2019

We have merged a PR which potentially fixes this.
Please try it out with VS Code insiders from Thursday and provide feedback here if it is behaving better. Thank you very much

@isidorn
Copy link
Contributor

isidorn commented Oct 23, 2019

Let me reopen since the PR probably does not fix the original isssue.
If we are mistaken, do let us know

@isidorn isidorn reopened this Oct 23, 2019
@isidorn isidorn modified the milestones: October 2019, On Deck Oct 23, 2019
@Tyriar Tyriar closed this as completed Oct 23, 2019
@joaomoreno joaomoreno reopened this Oct 24, 2019
@solomatov
Copy link
Contributor

@isidorn I had this issue on one of stable version of vs.code recently. It was just a file not revealed in the tree, and not completely unusable tree as Omar described.

@Tyriar
Copy link
Member

Tyriar commented Oct 31, 2019

Just happened to me again, next time it happens I'll try debug into explorerModel.findByPath and see if I can get more info.

@vscodebot vscodebot bot closed this as completed Nov 7, 2019
@vscodebot
Copy link

vscodebot bot commented Nov 7, 2019

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vscodebot
Copy link

vscodebot bot commented Nov 15, 2019

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@OmarTawfik
Copy link
Author

@Tyriar looks like it was closed by mistake?

@Tyriar Tyriar reopened this Nov 17, 2019
@Tyriar Tyriar removed the info-needed Issue requires more information from poster label Nov 17, 2019
@leolozes
Copy link

leolozes commented Apr 7, 2020

Had the same issue today with the last stable version. The fix given here #68627 (comment) worked, so maybe it's a regression?
I'm using it with WSL2 and the Remote-WSL extension.

@isidorn
Copy link
Contributor

isidorn commented Jun 9, 2020

This should be fixed now with latest vscode insdiers since I rewrote parts of exlporer responsible for this.
If you still see this please let me know and we can reopen this issue

@isidorn isidorn closed this as completed Jun 9, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
file-explorer Explorer widget issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants