Skip to content

Comments containing HTML tags can cause unhelpful error messages #17282

@danielj0nes

Description

@danielj0nes

Describe the bug

Both single-line and multi-line comments that contain certain HTML tags can break the parser and throw an internal server error.

It wasn’t easy to figure out what caused the issue, either, because Svelte for VS Code and the Vite error message incorrectly reported a missing semicolon.

It would be helpful to at least have a clearer warning or error message in this case.


Reproduction

// Adding a tag to this comment, such as this one: <style>
// will now break the parser.
function f(x) {
  ...
}

Vite output:

[plugin:vite-plugin-svelte:preprocess] Error while preprocessing placeholder.svelte
placeholder.svelte:4:30: Missed semicolon

System Info

System:
  OS: Linux 6.17 cpe:/o:nixos:nixos:25.11 25.11 (Xantusia)
  CPU: (16) x64 AMD Ryzen 7 PRO 8840U w/ Radeon 780M Graphics
  Memory: 22.89 GB / 30.01 GB
  Container: Yes
  Shell: 5.9 - /run/current-system/sw/bin/zsh

Binaries:
  Node: 22.21.1 - /run/current-system/sw/bin/node
  npm: 10.9.4 - /run/current-system/sw/bin/npm

Browsers:
  Chromium: 142.0.7444.162
  Firefox: 145.0
  Firefox Developer Edition: 145.0

npmPackages:
  svelte: ^5.41.0 => 5.43.6

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions