Enter-tainer / typst-preview

[DEPRECATED] Use tinymist instead
https://Enter-tainer.github.io/typst-preview/
MIT License
444 stars 21 forks source link

Crash upon failure to open a (non-existing) file #161

Closed Andrew15-5 closed 1 year ago

Andrew15-5 commented 1 year ago

Describe the bug I have a few ways to write a wrong path:

To Reproduce Steps to reproduce the behavior (Library test):

  1. read() an invalid file path
  2. See error

Expected behavior typst-preview should not crash on a temporary typst error.

Package/Software version:

typst-preview extension version: 0.8.2

Logs:

typst-preview server log(Output Panel -> typst-preview):

[2023-10-28T15:40:40Z INFO  typst_ts_compiler::service::diag] /file.typ: compiling ...
[2023-10-28T15:40:40Z INFO  typst_ts_compiler::service::diag] /file.typ: Compilation succeeded in 2.921572ms
[2023-10-28T15:40:40Z DEBUG typst_preview::actor::render] RenderActor: has_full_render: false
[2023-10-28T15:40:40Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2023-10-28T15:40:40Z DEBUG typst_preview::actor::webview] WebviewActor: received svg from renderer
[2023-10-28T15:40:41Z DEBUG typst_ts_compiler::service::compile] CompileActor: fs event incoming Some(Update(FileChangeSet { removes: [], inserts: [("/path/to/file.typ", FileSnapshot(Ok(NotifyFileRepr { mtime: SystemTime { tv_sec: 1698507641, tv_nsec: 203988642 }, content: bytes(2412) })))] }))
[2023-10-28T15:40:41Z INFO  typst_ts_compiler::service::diag] /file.typ: compiling ...
[2023-10-28T15:40:41Z INFO  typst_ts_compiler::service::diag] /file.typ: Compilation failed after 2.556282ms
error: file not found (searched at /path/to/path)
   ┌─ /path/to/.utils.typ:88:31
   │
88 │   ), breakable: true, raw(read(path), lang: lang))
   │                                ^^^^

help: error occurred in this call of function `include-code`
   ┌─ /path/to/file.typ:56:1
   │
56 │ #include-code("path", title: "file")
   │  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'typst-compiler' panicked at 'called `Result::unwrap()` on an `Err` value: NotFound("/path/to/path")', /home/user/.cargo/git/checkouts/typst.ts-bd03698c1f5efd74/004a0d3/compiler/src/vfs/mod.rs:189:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

typst-preview client log(Help -> Toggle Developer Tools -> Console):

nothing interesting
Enter-tainer commented 1 year ago

https://github.com/Enter-tainer/typst-preview/issues/151 a new release will fix this soon

Andrew15-5 commented 1 year ago

Ok, so, it still doesn't work because the next version of https://github.com/Myriad-Dreamin/typst.ts hasn't been released yet, right? Can I build that package and use it instead of latest version on crates.io or npmjs.com or whatever?

Enter-tainer commented 1 year ago

you can try. I'd recommand wait for the coming release.