withastro / language-tools

Language tools for Astro
MIT License
272 stars 54 forks source link

🐛 BUG: v2.11.0 is crashing with Sublime Text LSP 2.2.0 #895

Closed deathaxe closed 4 months ago

deathaxe commented 4 months ago

Describe the Bug

The following initialization request is made by Sublime Text 4's LSP plugin with a simple dummy astro project open, causing language server to crash while starting

:: [19:16:00.909] --> LSP-astro initialize (1): {'processId': 13260, 'clientInfo': {'name': 'Sublime Text LSP', 'version': '2.2.0'}, 'rootUri': 'file:///D:/JS/astro', 'rootPath': 'D:\\JS\\astro', 'workspaceFolders': [{'name': 'astro', 'uri': 'file:///D:/JS/astro'}], 'capabilities': {'general': {'regularExpressions': {'engine': 'ECMAScript'}, 'markdown': {'parser': 'Python-Markdown', 'version': '3.2.2'}}, 'textDocument': {'synchronization': {'dynamicRegistration': True, 'didSave': True, 'willSave': True, 'willSaveWaitUntil': True}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}, 'completion': {'dynamicRegistration': True, 'completionItem': {'snippetSupport': True, 'deprecatedSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'tagSupport': {'valueSet': [1]}, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertReplaceSupport': True, 'insertTextModeSupport': {'valueSet': [2]}, 'labelDetailsSupport': True}, '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]}, 'insertTextMode': 2, 'completionList': {'itemDefaults': ['editRange', 'insertTextFormat', 'data']}}, 'signatureHelp': {'dynamicRegistration': True, 'contextSupport': True, 'signatureInformation': {'activeParameterSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'parameterInformation': {'labelOffsetSupport': True}}}, 'references': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'documentSymbol': {'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': 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]}, 'tagSupport': {'valueSet': [1]}}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'formatting': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True, 'rangesSupport': True}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'codeAction': {'dynamicRegistration': True, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}, 'dataSupport': True, 'isPreferredSupport': True, 'resolveSupport': {'properties': ['edit']}}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True, 'prepareSupportDefaultBehavior': 1}, 'colorProvider': {'dynamicRegistration': True}, 'publishDiagnostics': {'relatedInformation': True, 'tagSupport': {'valueSet': [1, 2]}, 'versionSupport': True, 'codeDescriptionSupport': True, 'dataSupport': True}, 'diagnostic': {'dynamicRegistration': True, 'relatedDocumentSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'foldingRange': {'dynamicRegistration': True, 'foldingRangeKind': {'valueSet': ['comment', 'imports', 'region']}}, 'codeLens': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'semanticTokens': {'dynamicRegistration': True, 'requests': {'range': True, 'full': {'delta': True}}, 'tokenTypes': ['namespace', 'type', 'class', 'enum', 'interface', 'struct', 'typeParameter', 'parameter', 'variable', 'property', 'enumMember', 'event', 'function', 'method', 'macro', 'keyword', 'modifier', 'comment', 'string', 'number', 'regexp', 'operator', 'decorator'], 'tokenModifiers': ['declaration', 'definition', 'readonly', 'static', 'deprecated', 'abstract', 'async', 'modification', 'documentation', 'defaultLibrary'], 'formats': ['relative'], 'overlappingTokenSupport': False, 'multilineTokenSupport': True, 'augmentsSyntaxTokens': True}, 'callHierarchy': {'dynamicRegistration': True}, 'typeHierarchy': {'dynamicRegistration': True}}, 'workspace': {'applyEdit': True, 'didChangeConfiguration': {'dynamicRegistration': True}, 'executeCommand': {}, 'workspaceEdit': {'documentChanges': True, 'failureHandling': 'abort'}, 'workspaceFolders': True, 'symbol': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['location.range']}, '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]}, 'tagSupport': {'valueSet': [1]}}, 'configuration': True, 'codeLens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'semanticTokens': {'refreshSupport': True}, 'diagnostics': {'refreshSupport': True}}, 'window': {'showDocument': {'support': True}, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'workDoneProgress': True}}, 'initializationOptions': {'diagnosticModel': 2, 'typescript': {'tsdk': 'Sublime Text\\Data\\Package Storage\\LSP-astro\\21.6.1\\language-server\\node_modules\\typescript\\lib'}}}
:: [19:16:01.380] <~~ LSP-astro (1) (duration: 476ms): {'code': -32603, 'message': "Request initialize failed with message: Cannot read properties of undefined (reading 'selectionRangeProvider')"}
:: [19:16:01.380] --> LSP-astro shutdown

Server seems to fail initializing selectionRangeProvider. However disabling this capability client-side doesn't resolve / work around this issue.

Nothing changed but https://github.com/sublimelsp/LSP-astro/commit/9f9f6f4f8c15687169124f5f1c47c4b3e17ded38

Server starts properly with a commit before, running astro language server 2.10.x

Steps to Reproduce

  1. Start Sublime Text 4
  2. Install LSP
  3. Clone https://github.com/sublimelsp/LSP-astro into ST's "Packages" directory and checkout commit 9f9f6f4f8c15687169124f5f1c47c4b3e17ded38.
  4. Open an Astro project
  5. Server crashes upon initialization with message {'code': -32603, 'message': "Request initialize failed with message: Cannot read properties of undefined (reading 'selectionRangeProvider')"}
Princesseuh commented 4 months ago

Thank you for reporting this issue, we'll take a look!

Princesseuh commented 4 months ago

The package-lock.json in your project seems to be pointing to an old version of our dependencies: https://github.com/sublimelsp/LSP-astro/blob/9f9f6f4f8c15687169124f5f1c47c4b3e17ded38/language-server/package-lock.json#L626

We use the volar-2.4 tag on all of these: https://github.com/withastro/language-tools/blob/9e457653f59f3ffa9fa492145c56fd027b577217/packages/language-server/package.json#L33-L38, which at the time of writing points to 0.0.59. Maybe updating that lockfile would fix the problem.

deathaxe commented 4 months ago

Thanks for the quick reply.

I always relied on dependabot to do its job, but as it seems it didn't do that thoroughly enough.

Manually re-running npm upgrade fixed failing start.

Sorry for the noise.