denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.18k stars 5.37k forks source link

Panic when formatting simple html file #26560

Open andrewbrey opened 6 days ago

andrewbrey commented 6 days ago

I downloaded the contents of a webpage and attempted to format it with deno fmt and produced a panic. I then attempted to format the file with prettier which had no issues. I whittled the contents of the page down to see which part was causing the panic, and found that I can reliably reproduce with the following very simple html file contents:

As Code

<html>
    <body>
        <script>
            /* some multi-line comment
            with function below it */
            someFunc();
        </script>
    </body>
</html>

As Screenshot

image

Notably, if I do any of the following:

then no panic is produced.


Version: Deno 2.0.3

Output of RUST_BACKTRACE=1 deno fmt page.html

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 2.0.3
Args: ["deno", "fmt", "page.html"]

thread 'tokio-runtime-worker' panicked at cli/tools/fmt.rs:792:11:
Formatting not stable. Bailed after 5 tries. This indicates a bug in the formatter where it formats the file (<redacted>/page.html) differently each time. As a temporary workaround you can ignore this file.
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: tokio::runtime::task::raw::poll
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
bartlomieju commented 6 days ago

Traced back to https://github.com/dprint/dprint-plugin-typescript/issues/678