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

LSP server crashes when using custom json schema with vscode extension v0.19.0 (taplo/lsp v0.6.0) #355

Closed
ed-curran opened this issue Nov 23, 2022 · 3 comments

Comments

@ed-curran
Copy link

ed-curran commented Nov 23, 2022

Hey, thanks for your work on this extension / toolset particularly the LSP.

I've been trying to get the LSP to work with monaco in a browser and got some panics inside the LSP. At first I thought it was me because I wasn't getting them in vscode, however I then realized I was using v0.14.2 of the extension which uses an earlier version of the LSP and toolset etc. So then I installed v0.19.0 of the vscode extension and found I could reproduce the LSP crashes inside vscode. So must be something more fundamental.

The LSP crash manifests in vscode as vscode trying to restart the LSP, but getting stuck in a crash loop and then eventually it shows a little pop up.

The Even Better TOML LSP server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

But the real thing I'm interested in is why the LSP crashed in the first instance, although it raises the side question of why the LSP server fails to restart .

I can get the LSP to crash rather easily when using a custom json schema. Here's a test schema:

{
   "$ref": "#/definitions/TestSchema",
   "definitions": {
     "TestSchema": {
       "type": "object",
       "required": [
         "statements"
       ],
       "properties": {
         "statements": {
           "title": "stataments",
           "description": "statements description",
           "type": "array",
           "items": [
             {
               "title": "Create",
               "type": "object",
               "properties": {
                 "create": {
                   "description": "description for create object",
                   "title": "create",
                   "type": "object",
                   "properties": {
                     "a": {
                       "description": "description for property a",
                       "type": "string"
                     }
                   },
                   "required": [
                     "a"
                   ],
                   "additionalProperties": false
                 }
               },
               "required": [
                 "create"
               ],
               "additionalProperties": false
             }
           ]
         }
       }
     }
   }
 }
 

I can get the lsp to crash under these conditions:

  1. Request an auto completion (e.g. ctrl space shortcut) at the end of line 2
#:schema ./testSchema.json
[]

gets this error in extension logs

panicked at 'called `Option::unwrap()` on a `None` value', /home/runner/work/taplo/taplo/crates/taplo/src/util/mod.rs:169:10

Stack:

Error
    at AA.w.wbg.__wbg_new_693216e109162396 (/home/***/.vscode/extensions/tamasfe.even-better-toml-0.19.0/dist/server.js:2:5792)
    at wasm://wasm/00f689f6:wasm-function[5286]:0x320b3a
    at wasm://wasm/00f689f6:wasm-function[2552]:0x2dd09e
    at wasm://wasm/00f689f6:wasm-function[4322]:0x3163e4
    at wasm://wasm/00f689f6:wasm-function[4122]:0x312ad9
    at wasm://wasm/00f689f6:wasm-function[501]:0x1c9b5c
    at wasm://wasm/00f689f6:wasm-function[61]:0x103f3
    at wasm://wasm/00f689f6:wasm-function[102]:0x9c0a7
    at wasm://wasm/00f689f6:wasm-function[3144]:0x2f9465
    at wasm://wasm/00f689f6:wasm-function[74]:0x518ee
  1. Request an auto completion at the start of line 4
#:schema ./testSchema.json
[[statements]]
[statements.create]

gets error

panicked at 'called `Option::unwrap()` on a `None` value', /home/runner/work/taplo/taplo/crates/taplo-lsp/src/query.rs:259:37

Stack:

Error
    at AA.w.wbg.__wbg_new_693216e109162396 (/home/***/.vscode/extensions/tamasfe.even-better-toml-0.19.0/dist/server.js:2:5792)
    at wasm://wasm/00f689f6:wasm-function[5286]:0x320b3a
    at wasm://wasm/00f689f6:wasm-function[2552]:0x2dd09e
    at wasm://wasm/00f689f6:wasm-function[4322]:0x3163e4
    at wasm://wasm/00f689f6:wasm-function[4122]:0x312ad9
    at wasm://wasm/00f689f6:wasm-function[406]:0x1a3b59
    at wasm://wasm/00f689f6:wasm-function[61]:0x145f3
    at wasm://wasm/00f689f6:wasm-function[102]:0x9c0a7
    at wasm://wasm/00f689f6:wasm-function[3144]:0x2f9465
    at wasm://wasm/00f689f6:wasm-function[74]:0x518ee

I also noticed that in v0.14.2 I would have descriptions from the json schema show on hover, but this doesn't happen in v0.19.0.

My feeling is that the position of the cursor is getting out of sync with the state of the DOM, but that's just a guess. In my monaco troubleshooting I tried calling the textDocument/semanticTokens/full method on the LSP to get a look into the parsed representation, but it always returns an empty array regardless of the text of the editor which surprised me. I don't know if this is significant or not, I'm not familiar with LSP so I don't know what would be expected.

@xavdid
Copy link

xavdid commented Jan 31, 2023

I'm seeing this as well while setting files in a starship.toml file. They recommend starting the file with:

# Get editor completions based on the config schema
"$schema" = 'https://starship.rs/config-schema.json'

@chardoncs
Copy link

0.19.0 works fine for my Codium, but 0.19.1 keeps crashing after selecting a schema

@ia0
Copy link
Collaborator

ia0 commented Dec 12, 2023

This looks like a duplicate of #434 which has been fixed by #462 and waiting #473 to get released.

@ia0 ia0 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants