Prettier-vscode: Maximum call stack size exceeded on JavaScript file format

Created on 24 Jun 2017  路  15Comments  路  Source: prettier/prettier-vscode

  • 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.

bug locked need more info

Most helpful comment

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.

All 15 comments

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

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

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 ?

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
}

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.

Stalled, closing.

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

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

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

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 馃

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.

@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

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

@azz That was fast
Thanks 馃憤

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Levdbas picture Levdbas  路  4Comments

Connorelsea picture Connorelsea  路  4Comments

PetrykowskiM picture PetrykowskiM  路  3Comments

FlorianWendelborn picture FlorianWendelborn  路  3Comments

bluemoehre picture bluemoehre  路  3Comments