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

Custom view (TreeDataProvider) broken in 1.19.0 #40357

Closed
letmaik opened this issue Dec 16, 2017 · 13 comments
Closed

Custom view (TreeDataProvider) broken in 1.19.0 #40357

letmaik opened this issue Dec 16, 2017 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues verified Verification succeeded
Milestone

Comments

@letmaik
Copy link
Member

letmaik commented Dec 16, 2017

  • VSCode Version: Code 1.19.0 (816be67, 2017-12-14T12:06:43.492Z)
  • OS Version: Windows_NT x64 10.0.16299

I updated to 1.19.0 on several systems (all Windows) and on all of them my extension https://github.com/letmaik/vscode-git-tree-compare suddenly doesn't work anymore and I see a weird error in the console log:

  ERR Please return an array of children.: Error: Please return an array of children.
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:299:343
    at Object.g [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:139:729)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:143:568)
...

I couldn't find anything in the changelog which was related to breaking changes related to views.
The error message seems to come from https://github.com/Microsoft/vscode/blob/23affbd2b825e0782fc5e6c6a93db47db5511d49/src/vs/base/parts/tree/browser/treeModel.ts#L475 which calls the getChildren() method of the provider, but I always return an array, so I'm a bit confused what's going on. I'm also not sure how to debug directly into VS Code source code like treeModel.ts, which would help analyze this problem.

@vscodebot vscodebot bot added the debug Debug viewlet, configurations, breakpoints, adapter issues label Dec 16, 2017
@isidorn isidorn assigned sandy081 and unassigned isidorn Dec 18, 2017
@isidorn isidorn removed the debug Debug viewlet, configurations, breakpoints, adapter issues label Dec 18, 2017
@sandy081
Copy link
Member

@letmaik Is it possible to provide a sample that can reproduce this issue? It will be helpful to diagnose the issue correctly rather than doing some guess works.

@sandy081 sandy081 added tree-views Extension tree view issues info-needed Issue requires more information from poster labels Dec 18, 2017
@letmaik
Copy link
Member Author

letmaik commented Dec 18, 2017

Extracting a minimal example will take some effort (I can do it but currently I'm quite busy), I was hoping you guys have some debugger kung fu which would expose the root of the exception easily. In the mean time I was trying to debug the exception under a source-built VS Code (and then simply loading my extension into it via a .vsix file), but I got stuck at the boundary of some extension host proxy for the tree view. Let me know if you'd still like a minimal example, then I'll try to create one within the next weeks.

@sandy081
Copy link
Member

@letmaik This error can happen due to various reasons. I also have couple of variety of examples which cannot reproduce this. Hence, asking for the sample.

@mike-lischke
Copy link

mike-lischke commented Dec 23, 2017

I also get that error. I have a tree provider that is refreshed whenever the active editor changes and shows only for certain file types. This is the relevant code:

    getChildren(element?: Import): Thenable<Import[]> {
        if (!element) {
            let editor = window.activeTextEditor;
            if (editor && editor.document.languageId === "antlr") {
                let dependencies = this.backend.getDependencies(editor.document.fileName);
                let imports: Import[] = [];
                for (let dep of dependencies) {
                    imports.push(new Import(dep, TreeItemCollapsibleState.None));
                }
                return new Promise(resolve => {
                    resolve(imports);
                });
            }
        }

        return Promise.resolve([]);
    }

It all works nicely until the line return Promise.resolve([]); is executed the first time (usually for a file with a language id I don't want). From this moment on, switching to a supported type that returns a filled array (not an empty one), gives that said error.

@sandy081
Copy link
Member

sandy081 commented Jan 8, 2018

@mike-lischke Thanks for the snippet. I will use it to reproduce and fix it.

@sandy081 sandy081 added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Jan 8, 2018
@sandy081 sandy081 added this to the December 2017/January 2018 milestone Jan 8, 2018
@anikolaienko
Copy link

Hey guys,

I believe I have the same error on typescript files.
Here is the screenshot of what callstack I found:
screen shot 2018-01-13 at 8 54 49 pm

Not much, but the issue desapeared when I turned off 'TypeScript Hero' extension. HTH.

@sandy081
Copy link
Member

@letmaik @mike-lischke Unfortunately, I could not reproduce this bug with any of the tree samples I have, even after using the partial sample from @mike-lischke

I pushed an hypothetical fix which will be available in tomorrows insiders. Can you please verify your issue using that?

Thanks

sandy081 added a commit that referenced this issue Jan 25, 2018
@letmaik
Copy link
Member Author

letmaik commented Jan 25, 2018

@sandy081 I just pulled from master and ran vs code from there, it's fixed :) If you want to figure out why it's fixed you could install my extension https://github.com/letmaik/vscode-git-tree-compare and see what the behaviour is in the last vs code release vs master (look at the console where an exception will be if you open a git managed folder)

@sandy081
Copy link
Member

Thanks @letmaik

@sandy081 sandy081 added the verified Verification succeeded label Jan 26, 2018
@letmaik
Copy link
Member Author

letmaik commented Feb 8, 2018

I think this bug is not fully solved and your fix only hides the problem. I see the same behaviour as back then. Like in the past this issue appears randomly and not always, but it's quite reproducible.

@sandy081
Copy link
Member

sandy081 commented Feb 9, 2018

@letmaik Can you please provide steps to reproduce?

@letmaik
Copy link
Member Author

letmaik commented Feb 9, 2018

Yes, it's not minimal but it's very suitable for debugging:

  • Clone the debug-issue40357 branch of https://github.com/letmaik/vscode-git-tree-compare
  • Run npm install and then run the extension with F5 in vs code
  • You will see log output in the debugging console for each call to getChildren and getTreeItem including the returned values. You will see that in all cases getChildren returns a non-empty array and you will see there is a corresponding number of getTreeItem calls following that, again with the correct content.
  • If things work correctly, you see at least one tree item, otherwise none.

@sandy081
Copy link
Member

sandy081 commented Feb 9, 2018

@letmaik Thanks for the steps. Since this issue was closed, opened a new issue with the steps described by you.

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants