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

Error revealing files in the explorer #71588

Closed
DanTup opened this issue Apr 2, 2019 · 18 comments
Closed

Error revealing files in the explorer #71588

DanTup opened this issue Apr 2, 2019 · 18 comments

Comments

@DanTup
Copy link
Contributor

@DanTup DanTup commented Apr 2, 2019

Using Insiders 0ac1114 2019-04-01T15:39:08.133Z.

I had VS Code open and ran a command that created some files (see output pane), but they never appeared in the explorer. I opened dev tools and had this:

t.log @ /Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:235
/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:1408   ERR Data tree node not found: [object Object]: Error: Data tree node not found: [object Object]
    at Y.getDataNode (file:///Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:955:302)
    at Y.<anonymous> (file:///Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:953:631)
    at Generator.next (<anonymous>)
    at file:///Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:32:460
    at new Promise (<anonymous>)
    at n (file:///Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:32:237)
    at Y.expand (file:///Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:953:398)
    at e.<anonymous> (file:///Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:5248:778)
    at Generator.next (<anonymous>)
    at r (file:///Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:32:293)

Screenshot 2019-04-02 at 9 11 29 am

So far I can only reproduce by running some code I can't share (though it does seem reliable), but it essentially there's a single .dart file in the folder that's opened in VS Code, and the extension (during activation) detects that file, runs an external command that writes a bunch of files to this folder, then deletes the original file (it's creating a project from a template).

I'll see if I can make something hard-coded that triggers the same issue. If there's anything you want me to try, or if there's a way I can log the file system events or something that might shed light, let me know.

@isidorn

@vscodebot

This comment has been minimized.

Copy link

@vscodebot vscodebot bot commented Apr 2, 2019

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

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 2, 2019

Ok, here's an initial repro with publicly available bits, but you'll need a Dart SDK. I'll see if I can make a standalone repro.

  • Install the Dart SDK (either add to PATH, or browse to it when the extension asks you to)
  • Install the Dart extension
  • Run the Dart: New Project command (you have have to agree to activating Stagehand)
  • Select any template
  • Select a folder to create the project
  • A new window will spawn that opens that folder, Stagehand will be run to create the template, explorer will not update and the error is in the console
@isidorn isidorn self-assigned this Apr 2, 2019
@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 2, 2019

Struggling to get an isolated repro... This is essentially what I'm doing (and something very similar to this in the real extension triggers it). The only difference I can think of is that there's a lot more sync fs work before this code runs in the real extension (since we scan PATH looking for SDKs, etc.).

export function activate(context: ExtensionContext) {
	if (!workspace.workspaceFolders || !workspace.workspaceFolders.length) {
		window.showWarningMessage("Open a folder");
	}

// some other sync fs work here in real extension

	const wf = workspace.workspaceFolders![0];
	const dartTriggerFile = path.join(wf.uri.fsPath, "trigger.txt");
	if (fs.existsSync(dartTriggerFile)) {
		fs.unlinkSync(dartTriggerFile);
		createDartProject(wf.uri.fsPath);
	}
}

async function createDartProject(projectPath: string): Promise<boolean> {
	// const code = await vs.commands.executeCommand("_dart.create", projectPath, templateName) as number;
	// return code === 0;

	mkDirRecursive(path.join(projectPath, "lib/src/todo_list"));
	mkDirRecursive(path.join(projectPath, "test"));
	mkDirRecursive(path.join(projectPath, "web"));
	fs.writeFileSync(path.join(projectPath, ".gitignore"), "test");
	fs.writeFileSync(path.join(projectPath, "CHANGELOG.md"), "test");
	fs.writeFileSync(path.join(projectPath, "README.md"), "test");
	fs.writeFileSync(path.join(projectPath, "analysis_options.yaml"), "test");
	fs.writeFileSync(path.join(projectPath, "lib/app_component.css"), "test");
	fs.writeFileSync(path.join(projectPath, "lib/app_component.dart"), "test");
	fs.writeFileSync(path.join(projectPath, "lib/app_component.html"), "test");
	fs.writeFileSync(path.join(projectPath, "lib/src/todo_list/todo_list_component.css"), "test");
	fs.writeFileSync(path.join(projectPath, "lib/src/todo_list/todo_list_component.dart"), "test");
	fs.writeFileSync(path.join(projectPath, "lib/src/todo_list/todo_list_component.html"), "test");
	fs.writeFileSync(path.join(projectPath, "lib/src/todo_list/todo_list_service.dart"), "test");
	fs.writeFileSync(path.join(projectPath, "pubspec.yaml"), "test");
	fs.writeFileSync(path.join(projectPath, "test/app_test.dart"), "test");
	fs.writeFileSync(path.join(projectPath, "web/favicon.png"), "test");
	fs.writeFileSync(path.join(projectPath, "web/index.html"), "test");
	fs.writeFileSync(path.join(projectPath, "web/main.dart"), "test");
	fs.writeFileSync(path.join(projectPath, "web/styles.css"), "test");

	return true;
}

export function mkDirRecursive(folder: string) {
	const parent = path.dirname(folder);
	if (!fs.existsSync(parent)) {
		mkDirRecursive(parent);
	}
	if (!fs.existsSync(folder)) {
		fs.mkdirSync(folder);
	}
}
@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 2, 2019

Aha, the issue is when I try to immediately open one of the created files (which presumably has not yet been refreshed into the explorer):

commands.executeCommand("vscode.open", Uri.file(path.join(projectPath, "styles.css")));

Just wrapping up a complete repro...

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 2, 2019

Here's a complete repro:

https://github.com/DanTup/vscode-repro-err-data-tree-node-not-found (extension.ts).

Run the extension, then in the dev host, open the "folder_to_open" subfolder. It'll cause code to run that creates a file inside a subfolder and immediately tries to open it. The explorer won't refresh and the error will appear in the console.

In a quick test, it only seemed to occur when the created file was in a subfolder.

@isidorn

This comment has been minimized.

Copy link
Contributor

@isidorn isidorn commented Apr 2, 2019

@DanTup I can not access this repository https://github.com/DanTup/vscode-repro-err-data-tree-node-not-found
Can you make sure it is public and that the link you have provided is correct?
I also checked and could not find the repository under this list https://github.com/DanTup?utf8=%E2%9C%93&tab=repositories&q=vscode&type=&language=

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 2, 2019

@isidorn Oops sorry, didn't realise GH Desktop had pushed as private by default. Should be public now :)

@joaomoreno joaomoreno changed the title (Insiders) ERR Data tree node not found Error revealing files in the explorer Apr 2, 2019
@isidorn

This comment has been minimized.

Copy link
Contributor

@isidorn isidorn commented Apr 3, 2019

@DanTup now I can access the repo thanks!
However when I run the extension there is nothing happening.
Looking at the activation event I created a trigger.txt, however that files gets deleted and you extension adds a web folder with styles.css. Nowhere do I see a folder_to_open.
Can you please clarify this steps once I run the extension what to do exactly. Thanks

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 3, 2019

@isidorn There was a sample folder (which just includes a trigger.txt) in the repo:

https://github.com/DanTup/vscode-repro-err-data-tree-node-not-found/tree/master/folder_to_open

however that files gets deleted and you extension adds a web folder with styles.css

That's the expected behaviour, however the explorer tree doesn't update to show those changes, and there is the error in the console (in my testing, at least).

That said - I've just updated to the latest Insiders and it did not happen... Let me do a little more testing and post back!

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 3, 2019

No, I do still see it. I deleted what's in the folder, restored the trigger.txt, then did Reload Window and got this:

Screenshot 2019-04-03 at 11 43 37 am

The tree still shows the (now deleted) trigger.txt and not the new files, and the error is in the console.

@isidorn

This comment has been minimized.

Copy link
Contributor

@isidorn isidorn commented Apr 3, 2019

I can not reproduce. I tried multiple times. Are you doing something differently than me in this gif?

trigger

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 3, 2019

No, I am not :(

I'm using:

Version 1.33.0-insider (1.33.0-insider)
4d1cb56a5b88248b1e0f38b9980f4a1bc8a6fb1a
2019-04-03T08:01:08.572Z

I'm on macOS Mojave. I'm running in the dev host (opening the repo, pressing F5, then doing what you see here in the dev host). I'm not sure why we're seeing different behaviours :/

(sorry for the slow animation.. the mov2gif service I used slowed it down!)

Untitled (1)

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 3, 2019

I even tried it with Open Editors hidden, as you seem to have - but still repros 🤔

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 3, 2019

I presume the issue is related to it trying to highlight the current file in the Explorer tree, but it's running before the tree is updated from the files being created.

Have you disabled tracking of the current file? I notice that when styles.css opens, it doesn't track it in the explorer for you?

@isidorn

This comment has been minimized.

Copy link
Contributor

@isidorn isidorn commented Apr 4, 2019

@DanTup great guess! I forgot I have autoReveal: false. When I enable that I can reproduce this. Great steps, thanks a lot! Investigating...

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 8, 2019

@isidorn Thanks! Original error is gone, though I do see this error now - not sure if it's related:

Screenshot 2019-04-08 at 9 41 37 am

LMK if I should open a new issue.

@isidorn

This comment has been minimized.

Copy link
Contributor

@isidorn isidorn commented Apr 8, 2019

That does not seem to be related. feel free to open a new issue. Adding verified label per your comment.

@DanTup

This comment has been minimized.

Copy link
Contributor Author

@DanTup DanTup commented Apr 8, 2019

Done (#71935)! Thanks!

@vscodebot vscodebot bot locked and limited conversation to collaborators May 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.