rune-rs / rune

An embeddable dynamic programming language for Rust.
https://rune-rs.github.io
Apache License 2.0
1.7k stars 85 forks source link

Flaky auto-formatting in vscode / Rune LSP crashes #745

Open VorpalBlade opened 1 month ago

VorpalBlade commented 1 month ago

About half the time auto-formatting the current file in vscode (with the rune LSP installed) works, about half the time I get this popup instead:

image

The behaviour seems to have modes: That is, it works for a while, and then it doesn't until I restart the rune language server via the command palette.

I also see quite a few of these (and they are probably related:

[Info  - 18:30:04] Unhandled method `$/cancelRequest`
[Info  - 18:30:04] Unhandled method `$/cancelRequest`
[Info  - 18:30:08] Unhandled method `$/cancelRequest`
[Info  - 18:30:08] Unhandled method `$/cancelRequest`
[Info  - 18:30:08] Unhandled method `$/cancelRequest`
[Info  - 18:30:08] Unhandled method `$/cancelRequest`
[Info  - 18:30:08] Unhandled method `$/cancelRequest`
[Info  - 18:30:16] Unhandled method `$/cancelRequest`
[Info  - 18:30:19] Unhandled method `$/cancelRequest`
[Info  - 18:32:23] Unhandled method `$/cancelRequest`
[Info  - 18:32:36] Unhandled method `$/cancelRequest`
[Info  - 18:32:37] Connection to server got closed. Server will restart.
[Info  - 18:32:37] Starting language server
[Info  - 18:32:38] Connection to server got closed. Server will restart.
[Info  - 18:32:38] Starting language server
[Info  - 18:32:38] Connection to server got closed. Server will restart.
[Info  - 18:32:38] Starting language server
[Error - 18:32:39] The Rune Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

I don't see any backtraces, and there isn't any core dump in coredumpctl at least (not that I would expect that with Rust).

I do have few Rust crash in the log (further back), but it doesn't correspond to most "connection got closed" messages above (so we are probably looking at several different crashes here):

thread 'main' panicked at /home/arvid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/rope.rs:826:13:
Attempt to index past end of Rope: line index 101, Rope line length 101
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'main' panicked at /home/arvid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/rope.rs:826:13:
Attempt to index past end of Rope: line index 60, Rope line length 60
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'main' panicked at /home/arvid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/rope.rs:728:49:
called `Result::unwrap()` on an `Err` value: Utf16 code-unit index out of bounds: utf16 index 229, Rope/RopeSlice utf16 length 222
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

(not sure where to set RUST_BACKTRACE=1 for the LSP, so that it doesn't take effect in my terminals in vscode)

The rune cli I'm using is a "custom" one based on v0.13.3. cargo update indicates my Cargo.lock is up-to-date.