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

File name error causes Volar to crash #159

Closed
chizukicn opened this issue Apr 4, 2024 · 1 comment
Closed

File name error causes Volar to crash #159

chizukicn opened this issue Apr 4, 2024 · 1 comment
Labels
bug Something isn't working good reproduction ✨

Comments

@chizukicn
Copy link

chizukicn commented Apr 4, 2024

Describe the bug:

When I reference the @antv/g2 package in the vue file, volar will report an error and crash directly.

image

If I do not reference this package before opening vscode, volar will not crash if I reference this package after opening vscode.

If this package is referenced before open vscode, volar will crash directly.

So I think this should be a problem triggered by volar during initialization.

When I use vscode extension code debugging, this error is displayed as

image

When I added a try-catch where this function was called, volar no longer crashed.

// @volar/typescript/lib/protocol/createSys -> function directoryExists
    function directoryExists(dirName) {
        const oldDirName = dirName;
        dirName = resolvePath(dirName);
        const dir = getDir(dirName);
        if (dir.exists === undefined) {
            dir.exists = false;
            try{
                const result = env.fs?.stat(env.typescript.fileNameToUri(dirName));
                if (typeof result === 'object' && 'then' in result) {
                    const promise = result;
                    promises.add(promise);
                    result.then(result => {
                        promises.delete(promise);
                        dir.exists = result?.type === 2;
                        if (dir.exists) {
                            version++;
                        }
                    });
                }
                else {
                    dir.exists = result?.type === 2;
                }    
            }catch {

            }
        }
        return dir.exists;
    }

ps: This problem only occurs in volar versions 2.0.7 and above, and will not be triggered in volar 2.0.6

VSCode version: 1.87.2 (Universal)
VSCode Extension version: 2.0.8
Typescript version: 5.4.2
NodeJS version: 18.17.1
Operating System: macOS 14.4.1 (arm64 Apple silicon)
Reproduction Repository: https://github.com/chizukicn/volar_reproduction

@johnsoncodehk
Copy link
Member

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨
Projects
None yet
Development

No branches or pull requests

2 participants