Skip to content

bug: (neovim) crash when opening "virtual files" #2777

Open
@igorlfs

Description

@igorlfs

Describe the bug

When opening a "virtual file" (i.e., files that do not exist on disk) in neovim, the LSP crashes with the following error:

/usr/lib/node_modules/svelte-language-server/dist/src/plugins/typescript/LSAndTSDocResolver.js:201
            throw new Error('Cannot call getTSService without filePath and without tsconfigPath');
                  ^

Error: Cannot call getTSService without filePath and without tsconfigPath
    at LSAndTSDocResolver.getTSService (/usr/lib/node_modules/svelte-language-server/dist/src/plugins/typescript/LSAndTSDocResolver.js:201:19)
    at LSAndTSDocResolver.getOrCreateSnapshot (/usr/lib/node_modules/svelte-language-server/dist/src/plugins/typescript/LSAndTSDocResolver.js:118:38)
    at EventEmitter.<anonymous> (/usr/lib/node_modules/svelte-language-server/dist/src/plugins/typescript/LSAndTSDocResolver.js:42:22)
    at EventEmitter.emit (node:events:518:28)
    at DocumentManager.notify (/usr/lib/node_modules/svelte-language-server/dist/src/lib/documents/DocumentManager.js:118:22)
    at DocumentManager.openDocument (/usr/lib/node_modules/svelte-language-server/dist/src/lib/documents/DocumentManager.js:43:18)
    at DocumentManager.openClientDocument (/usr/lib/node_modules/svelte-language-server/dist/src/lib/documents/DocumentManager.js:25:21)
    at /usr/lib/node_modules/svelte-language-server/dist/src/server.js:296:37
    at handleNotification (/usr/lib/node_modules/svelte-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:640:25)
    at handleMessage (/usr/lib/node_modules/svelte-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:342:13)

Node.js v22.16.0

Reproduction

(0) Configure the server in neovim. E.g., use the default config for svelte from lspconfig.

  1. Launch neovim in a folder matching the configuration's root_markers (e.g., package.json or .git)
  2. Create and open a new "virtual file" with :edit foo://bar.svelte

Expected behaviour

The server shouldn't crash.

System Info

  • OS: Linux
  • IDE: Neovim

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions