Skip to content

Fix infinite recursion in the playground - #3305

Merged
duailibe merged 1 commit into
prettier:masterfrom
duailibe:fix-inf-site
Nov 22, 2017
Merged

duailibe merged 1 commit into
prettier:masterfrom
duailibe:fix-inf-site

Conversation

@duailibe

@duailibe duailibe commented Nov 22, 2017 •

Copy link
Copy Markdown
Collaborator

Fixes #3300

If there's an exception when formatting the code in playground, we check if it's because the parser was not yet loaded. This check was wrong for json and css|less|scss causing the code to recursive infinitely.

@duailibe duailibe changed the title Fix infinite loop in the playground Fix infinite recursion in the playground Nov 22, 2017
Comment thread website/static/worker.js Outdated
var script = "parser-" + actualParser + ".js";

if (!parsersLoaded[actualParser]) {
if (!parsersLoaded[parser]) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This means it will call importScripts again if you try to load css after loading scss, for example. Is that a big deal?

I could change the check above in line 97 instead to get the actual parser, but this seemed simpler.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about checking the status in lazyLoadParser()? so that the parsersLoaded is only used in one place.

image

@duailibe
duailibe merged commit c0fa47d into prettier:master Nov 22, 2017
@duailibe
duailibe deleted the fix-inf-site branch November 22, 2017 13:23
lipis added a commit to lipis/prettier that referenced this pull request Nov 24, 2017
* master:
  Don't add trailing comma after object rest spread in TypeScript  (prettier#3313)
  fix(cli): respect `--ignore-path` when using `--stdin-filepath` (prettier#3309)
  Fix infinite recursion in playground (prettier#3305)
  chore: setup markdown formatting (prettier#3224)
@lock lock Bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2019
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants