daidodo/format-imports

`Maximum call stack size exceeded` on large, minified JS file

Open

#36 aperta il 24 apr 2025

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)TypeScript (4 fork)github user discovery
bughelp wanted

Metriche repository

Star
 (51 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Describe the bug

Running format-imports on a large (60k LOC), minified JS file causes a crash with Maximum call stack size exceeded

$ npx format-imports pdf.worker.min.js
Maximum call stack size exceeded

I think it has to do with the specific minified code that is generated for this file, because other 60k LOC JS files work with no crashes with format-imports... 🤔

I believe this online minifier service was used to generate the code, with this original code (https://app.unpkg.com/pdfjs-dist@3.11.174/files/build/pdf.worker.js):

Minified code generated by the latest version of Terser or SWC Minifier does not appear to have the same problem with causing format-imports crashes.

To Reproduce Is there a demo repo to reproduce the issue?

https://github.com/karlhorky/repro-format-imports-maximum-call-stack-size-exceeded

Steps to reproduce the behavior:

  1. Clone repository
  2. Run npm run format or npx format-imports pdf.worker.min.js

Expected behavior

format-imports doesn't crash

Actual behavior

format-imports crashes

Screenshots

--

OS (please complete the following information):

  • OS: macOS
  • Version: Sequoia 15.4.1 (24E263)

Editor (please complete the following information):

  • Editor: VS Code
  • Version: 1.99.3

package.json (please remove any sensitive info)

{
  "name": "repro-format-imports-maximum-call-stack-size-exceeded",
  "version": "1.0.0",
  "author": "Karl Horky",
  "scripts": {
    "format": "format-imports pdf.worker.min.js"
  },
  "dependencies": {
    "format-imports": "4.0.7"
  }
}

tsconfig.json (if any)

none

.eslintrc.* (if any)

none

.prettierrc* (if any)

none

.editorconfig (if any)

none

Any more info

--

Guida contributor