nvarner / typst-lsp

A brand-new language server for Typst, plus a VS Code extension
MIT License
1.15k stars 78 forks source link

LSP Crashes #183

Closed ParadaCarleton closed 11 months ago

ParadaCarleton commented 1 year ago

Issue

The LSP seems to consistently crash after opening it.

Logs

[Info  - 10:30:26 PM] Folder added to workspace: file:///home/lime/.julia/dev/Quelia
[Info  - 10:30:26 PM] server initialized!
[Info  - 10:30:28 PM] New settings applied
[Info  - 10:31:03 PM] New settings applied
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/workspace/source_manager.rs:175:48
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
   3: typst_lsp::workspace::source_manager::SourceManager::get_inner_source
   4: typst_lsp::workspace::source_manager::SourceManager::get_all_by_uri
   5: <typst_lsp::lsp_typst_boundary::world::WorkspaceWorld as typst::World>::resolve
   6: typst::eval::import
   7: <typst::syntax::ast::ModuleImport as typst::eval::Eval>::eval
   8: <typst::syntax::ast::Expr as typst::eval::Eval>::eval
   9: typst::eval::eval_markup
  10: std::thread::local::LocalKey<T>::with
  11: typst::eval::eval
  12: typst_lsp::server::document::<impl typst_lsp::server::TypstServer>::on_source_changed::{{closure}}
  13: typst_lsp::server::lsp::<impl tower_lsp::LanguageServer for typst_lsp::server::TypstServer>::did_change::{{closure}}
  14: tower_lsp::jsonrpc::router::Router<S,E>::method::{{closure}}::{{closure}}::{{closure}}
  15: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  16: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
  18: <core::pin::Pin<P> as core::future::future::Future>::poll
  19: <tower_lsp::service::LspService<S> as tower_service::Service<tower_lsp::jsonrpc::Request>>::call::{{closure}}
  20: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  21: futures_util::stream::stream::StreamExt::poll_next_unpin
  22: <futures_util::stream::stream::buffer_unordered::BufferUnordered<St> as futures_core::stream::Stream>::poll_next
  23: <futures_util::stream::stream::map::Map<St,F> as futures_core::stream::Stream>::poll_next
  24: <futures_util::stream::stream::forward::Forward<St,Si,Item> as core::future::future::Future>::poll
  25: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  26: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
  27: tokio::runtime::park::CachedParkThread::block_on
  28: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  29: tokio::runtime::runtime::Runtime::block_on
  30: typst_lsp::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 10:34:55 PM] Connection to server got closed. Server will restart.
true
[Info  - 10:34:55 PM] Folder added to workspace: file:///home/lime/.julia/dev/Quelia
[Info  - 10:34:55 PM] server initialized!
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/workspace/source_manager.rs:175:48
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
   3: typst_lsp::workspace::source_manager::SourceManager::get_inner_source
   4: typst_lsp::workspace::source_manager::SourceManager::get_all_by_uri
   5: <typst_lsp::lsp_typst_boundary::world::WorkspaceWorld as typst::World>::resolve
   6: typst::eval::import
   7: <typst::syntax::ast::ModuleImport as typst::eval::Eval>::eval
   8: <typst::syntax::ast::Expr as typst::eval::Eval>::eval
   9: typst::eval::eval_markup
  10: std::thread::local::LocalKey<T>::with
  11: typst::eval::eval
  12: typst_lsp::server::document::<impl typst_lsp::server::TypstServer>::on_source_changed::{{closure}}
  13: typst_lsp::server::lsp::<impl tower_lsp::LanguageServer for typst_lsp::server::TypstServer>::did_change::{{closure}}
  14: tower_lsp::jsonrpc::router::Router<S,E>::method::{{closure}}::{{closure}}::{{closure}}
  15: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  16: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
  18: <core::pin::Pin<P> as core::future::future::Future>::poll
  19: <tower_lsp::service::LspService<S> as tower_service::Service<tower_lsp::jsonrpc::Request>>::call::{{closure}}
  20: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  21: futures_util::stream::stream::StreamExt::poll_next_unpin
  22: <futures_util::stream::stream::buffer_unordered::BufferUnordered<St> as futures_core::stream::Stream>::poll_next
  23: <futures_util::stream::stream::map::Map<St,F> as futures_core::stream::Stream>::poll_next
  24: <futures_util::stream::stream::forward::Forward<St,Si,Item> as core::future::future::Future>::poll
  25: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  26: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
  27: tokio::runtime::park::CachedParkThread::block_on
  28: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  29: tokio::runtime::runtime::Runtime::block_on
  30: typst_lsp::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 10:34:56 PM] Connection to server got closed. Server will restart.
true
[Info  - 10:34:57 PM] Folder added to workspace: file:///home/lime/.julia/dev/Quelia
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/workspace/source_manager.rs:175:48
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
   3: typst_lsp::workspace::source_manager::SourceManager::get_inner_source
   4: typst_lsp::workspace::source_manager::SourceManager::get_all_by_uri
   5: <typst_lsp::lsp_typst_boundary::world::WorkspaceWorld as typst::World>::resolve
   6: std::thread::local::LocalKey<T>::with
   7: comemo::cache::Cache::lookup
   8: std::thread::local::LocalKey<T>::with
   9: typst::eval::eval
  10: typst_lsp::server::document::<impl typst_lsp::server::TypstServer>::on_source_changed::{{closure}}
  11: typst_lsp::server::lsp::<impl tower_lsp::LanguageServer for typst_lsp::server::TypstServer>::did_open::{{closure}}
  12: tower_lsp::jsonrpc::router::Router<S,E>::method::{{closure}}::{{closure}}::{{closure}}
  13: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  14: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
  15: <core::pin::Pin<P> as core::future::future::Future>::poll
  16: <core::pin::Pin<P> as core::future::future::Future>::poll
  17: <tower_lsp::service::LspService<S> as tower_service::Service<tower_lsp::jsonrpc::Request>>::call::{{closure}}
  18: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  19: futures_util::stream::stream::StreamExt::poll_next_unpin
  20: <futures_util::stream::stream::buffer_unordered::BufferUnordered<St> as futures_core::stream::Stream>::poll_next
  21: <futures_util::stream::stream::map::Map<St,F> as futures_core::stream::Stream>::poll_next
  22: <futures_util::stream::stream::forward::Forward<St,Si,Item> as core::future::future::Future>::poll
  23: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  24: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
  25: tokio::runtime::park::CachedParkThread::block_on
  26: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  27: tokio::runtime::runtime::Runtime::block_on
  28: typst_lsp::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 10:34:57 PM] Connection to server got closed. Server will restart.
true
[Info  - 10:34:57 PM] Folder added to workspace: file:///home/lime/.julia/dev/Quelia
[Info  - 10:34:57 PM] server initialized!
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/workspace/source_manager.rs:175:48
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
   3: typst_lsp::workspace::source_manager::SourceManager::get_inner_source
   4: typst_lsp::workspace::source_manager::SourceManager::get_all_by_uri
   5: <typst_lsp::lsp_typst_boundary::world::WorkspaceWorld as typst::World>::resolve
   6: typst::eval::import
   7: <typst::syntax::ast::ModuleImport as typst::eval::Eval>::eval
   8: <typst::syntax::ast::Expr as typst::eval::Eval>::eval
   9: typst::eval::eval_markup
  10: std::thread::local::LocalKey<T>::with
  11: typst::eval::eval
  12: typst_lsp::server::document::<impl typst_lsp::server::TypstServer>::on_source_changed::{{closure}}
  13: typst_lsp::server::lsp::<impl tower_lsp::LanguageServer for typst_lsp::server::TypstServer>::did_change::{{closure}}
  14: tower_lsp::jsonrpc::router::Router<S,E>::method::{{closure}}::{{closure}}::{{closure}}
  15: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  16: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
  18: <core::pin::Pin<P> as core::future::future::Future>::poll
  19: <tower_lsp::service::LspService<S> as tower_service::Service<tower_lsp::jsonrpc::Request>>::call::{{closure}}
  20: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  21: futures_util::stream::stream::StreamExt::poll_next_unpin
  22: <futures_util::stream::stream::buffer_unordered::BufferUnordered<St> as futures_core::stream::Stream>::poll_next
  23: <futures_util::stream::stream::map::Map<St,F> as futures_core::stream::Stream>::poll_next
  24: <futures_util::stream::stream::forward::Forward<St,Si,Item> as core::future::future::Future>::poll
  25: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  26: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
  27: tokio::runtime::park::CachedParkThread::block_on
  28: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  29: tokio::runtime::runtime::Runtime::block_on
  30: typst_lsp::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 10:34:57 PM] Connection to server got closed. Server will restart.
true
[Info  - 10:34:57 PM] Folder added to workspace: file:///home/lime/.julia/dev/Quelia
[Info  - 10:34:57 PM] server initialized!
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/workspace/source_manager.rs:175:48
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
   3: typst_lsp::workspace::source_manager::SourceManager::get_inner_source
   4: typst_lsp::workspace::source_manager::SourceManager::get_all_by_uri
   5: <typst_lsp::lsp_typst_boundary::world::WorkspaceWorld as typst::World>::resolve
   6: typst::eval::import
   7: <typst::syntax::ast::ModuleImport as typst::eval::Eval>::eval
   8: <typst::syntax::ast::Expr as typst::eval::Eval>::eval
   9: typst::eval::eval_markup
  10: std::thread::local::LocalKey<T>::with
  11: typst::eval::eval
  12: typst_lsp::server::document::<impl typst_lsp::server::TypstServer>::on_source_changed::{{closure}}
  13: typst_lsp::server::lsp::<impl tower_lsp::LanguageServer for typst_lsp::server::TypstServer>::did_change::{{closure}}
  14: tower_lsp::jsonrpc::router::Router<S,E>::method::{{closure}}::{{closure}}::{{closure}}
  15: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  16: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
  18: <core::pin::Pin<P> as core::future::future::Future>::poll
  19: <tower_lsp::service::LspService<S> as tower_service::Service<tower_lsp::jsonrpc::Request>>::call::{{closure}}
  20: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  21: futures_util::stream::stream::StreamExt::poll_next_unpin
  22: <futures_util::stream::stream::buffer_unordered::BufferUnordered<St> as futures_core::stream::Stream>::poll_next
  23: <futures_util::stream::stream::map::Map<St,F> as futures_core::stream::Stream>::poll_next
  24: <futures_util::stream::stream::forward::Forward<St,Si,Item> as core::future::future::Future>::poll
  25: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
  26: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
  27: tokio::runtime::park::CachedParkThread::block_on
  28: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  29: tokio::runtime::runtime::Runtime::block_on
  30: typst_lsp::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 10:34:57 PM] The Typst Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
RolfBremer commented 1 year ago

I have the same problem, here on Windows 11 with VS-Code.

Andrew15-5 commented 1 year ago

v0.7.0 & 0.7.1 don't work with mason.nvim in Neovim. Only if I type :MasonInstall typst-lsp@v0.6.2 and do CocRestart (or re-open) it will work. coc.nvim and mason.nvim don't produce any logs that show that typst-lsp server has failed.

Andrew15-5 commented 1 year ago

Logs

You should enclose long text (code, logs etc.) in <details> tag (optionally with <summary>):

<details><summary>Optional name</summary>

< your logs >

</details>

https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections#creating-a-collapsed-section

lucaspar commented 12 months ago

Same problem happening here.

It seems to be caused by missing files in import statements, like #import "missing.typ": *

When I remove the import the problem goes away. It'd be nice to have it more robust.

Andrew15-5 commented 11 months ago

@nvarner, will the release assets be added later? I wanted to try the new version, but mason tells me:

Failed to download file "https://github.com/nvarner/typst-lsp/releases/download/v0.7.2/typst-lsp-linux-x64".

https://github.com/nvarner/typst-lsp/releases/tag/v0.7.2

nvarner commented 11 months ago

@Andrew15-5 if you haven't yet seen, the assets are up now. They get uploaded automatically by GH Actions, which itself is triggered by creating the release, so there's usually a short delay.

Andrew15-5 commented 11 months ago

Oh, wow, you can even manage assets automatically, I should check it out. Thanks.

Andrew15-5 commented 11 months ago

mason only updates to 0.7.1, but 0.7.2 also still doesn't work. (https://github.com/nvarner/typst-lsp/issues/183#issuecomment-1634570927)

I don't know if this is still related to this issue, since I can't get any logs from coc and mason.