Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stack overflow when formatting large templates #1668

Merged
merged 2 commits into from
Mar 1, 2021

Conversation

shenglol
Copy link
Contributor

@shenglol shenglol commented Mar 1, 2021

Fixes #1636. Also updated the client to support the insertFinalNewline option which fixes #997.

{
return new NestDocument(level + this.Level, this.Successor.Nest(level));
RuntimeHelpers.EnsureSufficientExecutionStack();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RuntimeHelpers.EnsureSufficientExecutionStack() [](start = 12, length = 47)

Is the DocumentBuildVisitor ultimately driving the recursion here? If yes, would it make sense to have one call to RuntimeHelpers.EnsureSufficientExecutionStack() there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, we'd have to stick this everywhere :(


In reply to: 585109461 [](ancestors = 585109461)

Copy link
Contributor Author

@shenglol shenglol Mar 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DocumentBuildVisitor is driving the recursion, but if I understand it correctly putting it in the parent method call won't help as it checks that if the stack has enough space to support next method call.

Copy link
Member

@majastrz majastrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@shenglol shenglol merged commit 2812732 into main Mar 1, 2021
@shenglol shenglol deleted the shenglol/fix-formatter-stack-overflow branch March 1, 2021 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants