prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

Maximum call stack size exceeded on JavaScript file format

Open edaloicaro18 opened this issue 9 years ago • 15 comments

  • VSCode Version: 1.13.1 (379d2efb5539b09112c793d3d9a413017d736f89)

  • OS : Windows 10 Pro

Steps to Reproduce:

  1. Open JavaScript file with wrong indentation
  2. Hit Shift+Alt+F
  3. Maximum call stack size exceeded

I tried disabling each and every extension in VSCode and then enabling them one by one and the only one that gave me that error is this extension.

edaloicaro18 avatar Jun 24 '17 21:06 edaloicaro18

Do you have a deeply nested code? Can you share the code which produce this error?

CiGit avatar Jun 24 '17 22:06 CiGit

Well I don't have a git repo, but I've got this sandbox

edaloicaro18 avatar Jun 24 '17 22:06 edaloicaro18

Which file? I've no trouble with the ones I've tried. I would prefer If you could copy paste the code in this issue. Can you share your settings ?

CiGit avatar Jun 25 '17 07:06 CiGit

At first, I thought it had something to do with the JSX in my JS files but then tried to format other types of documents containing pure JS or even HTML and the problem was the same.

You can try with all the files inside the "components" folder

You mean the user settings, right?

{
    "workbench.colorTheme": "Cobalt2",
    "workbench.iconTheme": "vs-seti",
    "window.zoomLevel": 0,
    "emmet.syntaxProfiles": {
        "javascript": "jsx"
    },
    "editor.minimap.enabled": false
}

edaloicaro18 avatar Jun 25 '17 13:06 edaloicaro18

Yes those settings. Nothing relevant to this extension. I've no errors at all. Can you try to uninstall / reinstall the extension (at that point I don't know really) Can you also try with eslintIntegration true.

CiGit avatar Jun 25 '17 17:06 CiGit

Stalled, closing.

CiGit avatar Jul 15 '17 10:07 CiGit

I also started facing this issue almost randomly. Prettier was working before. Installing prettier locally fixed it for me.

anantoghosh avatar Sep 30 '17 17:09 anantoghosh

Which version did you install locally? Which file did this error? What are your settings?

CiGit avatar Sep 30 '17 17:09 CiGit

I think we have 1 recursive call (find package.json) So if your path is 10k folders deep, it may happen Oo Maybe in prettier if you have deeply nested calls. dunno

Hypothesis: 10k is still the call stack size :-D

CiGit avatar Sep 30 '17 17:09 CiGit

I installed prettier 1.7.3 locally. Threw error on every file. After about 3 seconds after calling format document. Default settings.

I'm currently busy with work and can't throughly examine it right now. It doesn't seem like many people face this problem. I'll try to help once I'm free 🤞

anantoghosh avatar Sep 30 '17 19:09 anantoghosh

Maximum call stack size exceeded: RangeError: Maximum call stack size exceeded
    at new fs.Stats (fs.js:133:20)
    at fs.statSync (fs.js:912:18)
    at Object.fs.statSync (ELECTRON_ASAR.js:280:16)
    at typeSync (C:\Users\username\.vscode\extensions\esbenp.prettier-vscode-0.23.1\node_modules\path-type\index.js:18:15)
    at Function.module.exports.sync (C:\Users\username\.vscode\extensions\esbenp.prettier-vscode-0.23.1\node_modules\read-pkg\index.js:38:16)
    at Function.module.exports.sync.opts [as sync] (C:\Users\username\.vscode\extensions\esbenp.prettier-vscode-0.23.1\node_modules\read-pkg-up\index.js:23:16)
    at findPkg (C:\Users\username\.vscode\extensions\esbenp.prettier-vscode-0.23.1\out\src\requirePkg.js:7:27)
    at findPkg (C:\Users\username\.vscode\extensions\esbenp.prettier-vscode-0.23.1\out\src\requirePkg.js:14:16)
    at findPkg (C:\Users\username\.vscode\extensions\esbenp.prettier-vscode-0.23.1\out\src\requirePkg.js:14:16)
    at findPkg (C:\Users\username\.vscode\extensions\esbenp.prettier-vscode-0.23.1\out\src\requirePkg.js:14:16)

Currently I have a project with prettier installed locally where there is no problem. And for rest I get the error above.

anantoghosh avatar Sep 30 '17 19:09 anantoghosh

@CiGit I've found my problem: findPkg is indeed the culprit.

(on Windows) My project folder was D:\Develop\http\ and I had a package.json file in D: which I had just copied from a project.

1st call 1

2nd call 2

3rd call (this keeps repeating) 3

read-pkg-up with fspath D:\ keeps finding D:\package.json. and

path.resolve(path.dirname(res.path), '..')

resolves to D:\ again.

Removing the package.json from the root drive (D:) makes prettier-vscode work again

anantoghosh avatar Oct 13 '17 11:10 anantoghosh

Thanks @anantoghosh for debugging this. I've opened a PR to fix this at #241

azz avatar Oct 13 '17 12:10 azz

@azz That was fast Thanks 👍

anantoghosh avatar Oct 13 '17 12:10 anantoghosh

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Apr 13 '20 06:04 github-actions[bot]