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

Write out JS comments when there would be 4 or more consecutive tildes in generated Html #10805

Merged
merged 7 commits into from
Aug 29, 2024

Conversation

davidwengier
Copy link
Contributor

Fixes https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2222322

Our use of tildes as replacement characters for C# in Html documents has never been great, and has caused issues with JS/TS and Html tooling in the past, but it seems there are scenarios where large/complicated/specifically formed Razor documents can actually crash the JS compiler. Seems it has a perf issue where lots of unary negation (ie, ~) causes stack size issues.

This PR mitigates the issue by encoding any stretch of C# characters that are 4 characters or longer as a JS comment (/*~~~*/) so that the compiler will ignore some of the more problematic chunks of Razor files. There is one case where we couldn't do that, but any pressure relief should help even if it's not 100%.

@davidwengier davidwengier requested review from a team as code owners August 28, 2024 05:15
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The contents, and indeed the expected state of this file, are not important. What is important is that merely opening up the file without the changes in this PR instantly crashes the JS compiler and breaks the editor.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps add a comment mentioning that (e.g., linking the issue) so we know what's the purpose of the test in the future.

@davidwengier
Copy link
Contributor Author

Fun fact: If you stare at enough JS comments in diffs they start to look like worried little guys

Copy link
Member

@jjonescz jjonescz left a comment

Choose a reason for hiding this comment

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

LGTM. If I understand correctly, this doesn't even impact the compiler, just tooling, right?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps add a comment mentioning that (e.g., linking the issue) so we know what's the purpose of the test in the future.

@davidwengier
Copy link
Contributor Author

Correct. This is a little piece of tooling that lives in the compiler, but even with FUSE, it shouldn't run during actual builds.

@davidwengier
Copy link
Contributor Author

davidwengier commented Aug 28, 2024

Fixed one integration test (lucked into an unstable formatting result), the other two failing tests are also failing in main so shouldn't be blocking.

UPDATE: Failing integration tests fixed in #10807

@davidwengier
Copy link
Contributor Author

@dotnet/razor-compiler for second review thanks

@davidwengier
Copy link
Contributor Author

Anyone on @dotnet/razor-tooling want to share an opinion?

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

I opine :shipit:

@davidwengier davidwengier merged commit 1f45c70 into main Aug 29, 2024
15 of 17 checks passed
@davidwengier davidwengier deleted the dev/dawengie/WriteHtmlDocsWithComments branch August 29, 2024 07:43
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 29, 2024
@phil-allen-msft phil-allen-msft modified the milestones: Next, 17.12 P3 Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants