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

VLS crashes for *.vue files in node_modules #2006

Closed
3 tasks done
kapitanluffy opened this issue Jun 23, 2020 · 10 comments
Closed
3 tasks done

VLS crashes for *.vue files in node_modules #2006

kapitanluffy opened this issue Jun 23, 2020 · 10 comments

Comments

@kapitanluffy
Copy link

kapitanluffy commented Jun 23, 2020

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: Win 10
  • Vetur version: 0.24
  • Sublime Text Version: 3.2.2

Problem

lsp-vue: Loaded bundled typescript@3.9.5.
lsp-vue: Vetur initialized
:: --> lsp-vue initialize(1): {'clientInfo': {'version': '0.11.2', 'name': 'Sublime Text LSP'}, 'initializationOptions': {'config': {'html': {'suggest': {}}, 'typescript': {'format': {}}, 'stylusSupremacy': {}, 'vetur': {'useWorkspaceDependencies': False, 'validation': {'style': True, 'script': True, 'template': True}, 'completion': {'tagCasing': 'kebab', 'useScaffoldSnippets': False, 'autoImport': False}, 'format': {'defaultFormatter': {'js': 'none', 'ts': 'none'}, 'options': {'useTabs': False, 'tabSize': 4}, 'scriptInitialIndent': False, 'defaultFormatterOptions': {}, 'enable': True, 'styleInitialIndent': False}, 'experimental': {'templateInterpolationService': True}}, 'javascript': {'format': {}}, 'css': {}, 'emmet': {}}}, 'processId': 139716, 'rootUri': 'file:///V:/MyProject', 'capabilities': {'workspace': {'symbol': {'dynamicRegistration': True, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, 'applyEdit': True, 'configuration': True, 'executeCommand': {}, 'workspaceEdit': {'failureHandling': 'abort', 'documentChanges': True}, 'workspaceFolders': True, 'didChangeConfiguration': {'dynamicRegistration': True}}, 'experimental': {}, 'textDocument': {'hover': {'contentFormat': ['markdown', 'plaintext'], 'dynamicRegistration': True}, 'formatting': {'dynamicRegistration': True}, 'definition': {'linkSupport': True, 'dynamicRegistration': True}, 'rename': {'dynamicRegistration': True}, 'synchronization': {'didSave': True, 'willSave': True, 'willSaveWaitUntil': True, 'dynamicRegistration': True}, 'references': {'dynamicRegistration': True}, 'documentSymbol': {'hierarchicalDocumentSymbolSupport': True, 'dynamicRegistration': True, 'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, 'completion': {'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, 'completionItem': {'snippetSupport': True}, 'dynamicRegistration': True}, 'implementation': {'linkSupport': True, 'dynamicRegistration': True}, 'publishDiagnostics': {'relatedInformation': True}, 'colorProvider': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True}, 'signatureHelp': {'dynamicRegistration': True, 'signatureInformation': {'parameterInformation': {'labelOffsetSupport': True}, 'documentationFormat': ['markdown', 'plaintext']}}, 'typeDefinition': {'linkSupport': True, 'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'codeAction': {'codeActionLiteralSupport': {'codeActionKind': {'valueSet': []}}, 'dynamicRegistration': True}, 'declaration': {'linkSupport': True, 'dynamicRegistration': True}}, 'window': {'workDoneProgress': True}}, 'workspaceFolders': [{'uri': 'file:///V:/MyProject', 'name': 'MyProject'}, {'uri': 'file:///V:/MyProject/resources/workspaces/router', 'name': 'router'}, {'uri': 'file:///V:/MyProject/modules/drivers', 'name': 'drivers'}, {'uri': 'file:///V:/MyProject/system', 'name': 'system'}, {'uri': 'file:///V:/MyProject/themes/frontend', 'name': 'frontend'}, {'uri': 'file:///V:/MyProject/themes/backend', 'name': 'backend'}], 'rootPath': 'v:\\MyProject'}
:: <<< lsp-vue 1: {'capabilities': {'textDocumentSync': 1, 'referencesProvider': True, 'signatureHelpProvider': {'triggerCharacters': ['(']}, 'documentLinkProvider': {'resolveProvider': False}, 'completionProvider': {'resolveProvider': True, 'triggerCharacters': ['.', ':', '<', '"', "'", '/', '@', '*']}, 'colorProvider': True, 'hoverProvider': True, 'documentHighlightProvider': True, 'codeActionProvider': True, 'documentFormattingProvider': False, 'documentSymbolProvider': True, 'definitionProvider': True}}
::  -> lsp-vue initialized: {}
::  -> lsp-vue textDocument/didOpen
lsp-vue: D:\~\bin\vetur\server\node_modules\typescript\lib\typescript.js:2251
lsp-vue: throw e;
lsp-vue: ^
lsp-vue: 
lsp-vue: Error: Debug Failure. Expected 3 === 1. Registered script kind should match new script kind.
lsp-vue: at Object.getOrCreateSourceFileByPath [as getSourceFileByPath] (D:\~\bin\vetur\server\node_modules\typescript\lib\typescript.js:139326:34)
lsp-vue: at tryReuseStructureFromOldProgram (D:\~\bin\vetur\server\node_modules\typescript\lib\typescript.js:100516:28)
lsp-vue: at Object.createProgram (D:\~\bin\vetur\server\node_modules\typescript\lib\typescript.js:100099:30)

Reproducible Case

Crashes when restarting vue language server

LSP plugin settings

"lsp-vue":
{
	"command":
	[
		"node",
		"D:/~/bin/vetur/server/bin/vls",
		"--stdio"
	],
	"enabled": true
},
@rchl
Copy link
Collaborator

rchl commented Jun 23, 2020

This question probably belongs in sublime LSP repo.

In any case, you need to provide configuration for VLS server which you didn't.

I'd suggest you remove that configuration and try https://github.com/sublimelsp/LSP-vue instead. It provides base configuration and manages server dependency for you.

@kapitanluffy
Copy link
Author

If I use the server used by LSP-vue, I will encounter this issue which will then redirect me to this issue and lastly to this issue in this repo.

I am creating this issue because I had a similar error from this issue.

This is why I cloned vetur itself to use the included server. I cloned and compiled the server using npm run compile under the server directory. It does work but it randomly crashes with that error.

@rchl
Copy link
Collaborator

rchl commented Jun 23, 2020

OK, then just take the options from https://github.com/sublimelsp/LSP-vue/blob/master/LSP-vue.sublime-settings and include in your configuration.

Something like this
"lsp-vue":
{
    "enabled": true
    "command":
    [
        "node",
        "D:/~/bin/vetur/server/bin/vls",
        "--stdio"
    ],
    "languages": [
        {
            "languageId": "vue",
            "scopes": ["text.html.vue"],
            "syntaxes": ["Packages/Vue Syntax Highlight/Vue Component.sublime-syntax"],
        }
    ],
    "initializationOptions": {
        "config": {
            "vetur": {
                "completion": {
                    "autoImport": false,
                    "tagCasing": "kebab",
                    "useScaffoldSnippets": false,
                },
                "experimental": {
                    "templateInterpolationService": true,
                },
                "format": {
                    "enable": true,
                    "defaultFormatter": {
                        "js": "none",
                        "ts": "none",
                    },
                    "defaultFormatterOptions": {},
                    "scriptInitialIndent": false,
                    "styleInitialIndent": false,
                    "options": {
                        // tabSize and useTabs will be automatically inferred from the workspace
                    },
                },
                "useWorkspaceDependencies": false,
                "validation": {
                    "script": true,
                    "style": true,
                    "template": true,
                },
            },
            "css": {
                "validate": true,
                "completion": {
                    "triggerPropertyValueCompletion": true,
                    "completePropertyWithSemicolon": true,
                },
                "customData": [],
                "lint": {
                    "compatibleVendorPrefixes": "ignore",
                    "vendorPrefix": "warning",
                    "duplicateProperties": "ignore",
                    "emptyRules": "warning",
                    "importStatement": "ignore",
                    "boxModel": "ignore",
                    "universalSelector": "ignore",
                    "zeroUnits": "ignore",
                    "fontFaceProperties": "warning",
                    "hexColorLength": "error",
                    "argumentsInColorFunction": "error",
                    "unknownProperties": "warning",
                    "validProperties": [],
                    "ieHack": "ignore",
                    "unknownVendorSpecificProperties": "ignore",
                    "propertyIgnoredDueToDisplay": "warning",
                    "important": "ignore",
                    "float": "ignore",
                    "idSelector": "ignore",
                    "unknownAtRules": "warning",
                },

            },
            "emmet": {},
            "stylusSupremacy": {},
            "html": {
                "suggest": {},
            },
            "javascript": {
                "format": {},
            },
            "typescript": {
                "format": {},
            }
        }
    },
    "settings": {}
},

@kapitanluffy
Copy link
Author

I appreciate this. I am using the LSP-vue plugin and overriding the "command" key in the settings as provided above to use my own server. I believe the settings are already being merged by the plugin automatically to produce the json you provided.

@rchl
Copy link
Collaborator

rchl commented Jun 23, 2020

Hmm, maybe it's the case but it's sort of undocumented feature and I would not rely on that. Better to just remove the LSP-vue plugin then and use your own configuration.

@kapitanluffy
Copy link
Author

kapitanluffy commented Jun 23, 2020

oh. just for clarification, it does not randomly crash. I just realized again that it crashes only on vue files under node_modules similar to this issue that is why I commented issue before 😅

@octref
Copy link
Member

octref commented Aug 7, 2020

@kapitanluffy Does this still repro in latest version? Setting ScriptKind to Deferred might have helped, but I'm not 100% sure: #1979

3 => TS, 1 => JS.
Can you try to create a repro out of https://github.com/octref/veturpack? Just create an empty folder and put some Vue files into it to make it crash, and push your fork.

@kapitanluffy
Copy link
Author

kapitanluffy commented Aug 14, 2020

@octref here's my fork. It uses the manually cloned/compiled vetur repository. Try opening the vue files inside the vue2-google-maps package.
https://github.com/kapitanluffy/veturpack

image

  • typescript: 3.9.5
  • vetur: 0.26.1
  • vls: 0.4.1

@kapitanluffy kapitanluffy changed the title Debug Failure. Expected 3 === 1. Registered script kind should match new script kind. Vue language server crashes when vue files under node_modules are opened Aug 14, 2020
@kapitanluffy kapitanluffy changed the title Vue language server crashes when vue files under node_modules are opened VLS crashes for *.vue files in node_modules Aug 14, 2020
@kapitanluffy
Copy link
Author

kapitanluffy commented Aug 14, 2020

I tried installing another server from npm itself, same results.

image

  • typescript: 3.9.7
  • vls: 0.4.2

@octref
Copy link
Member

octref commented Aug 26, 2020

Thanks for the repro. I disabled diagnostics for any vue files in node_modules. Should improve perf as well.

@octref octref closed this as completed in f53de02 Aug 26, 2020
cereschen pushed a commit to cereschen/vetur that referenced this issue Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants