Skip to content

Formatting large json file stuck and CPU 100% usage #1293

Closed
denoland/deno
#29162
@qupig

Description

@qupig

Describe the bug

When formatting a large JSON file, and the current indentWidth is different from the target indentWidth, formatting the file will be stuck for a long time, and can be seen in the deno process CPU 100% utilization.

If config VSCode auto format when saving the file, it will block the SAVE operation, even after clicking SKIP it still doesn't work.

Note:

  • No problem when formatting from stringify JSON files
  • The problem only seems to occur when indentWidth is different
  • The deno fmt 1.json command is fine. This only happens with the Deno-VSCode-Extension.
  • There is no problem using VSCode's built-in formatting or Prettier extension
  • I've reproduced the issue in at least 2 devices

To Reproduce

Please see attached demo project:

  1. deno -W main.ts generates 1.json.
  2. Format the 1.json (no problem)
  3. Change the target indentWidth config
  4. Format the 1.json file again

Steps 3-4 can be modified and tested repeatedly.

Screenshots

deno-vscode-fmt-bug-demo.mp4

demo.zip

Versions

vscode: 1.99.3 deno: 2.3.1 extension: 3.44.1

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