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

Slow store cannot run profiler on any page #94

Closed
icantrank opened this issue Jun 2, 2021 · 5 comments
Closed

Slow store cannot run profiler on any page #94

icantrank opened this issue Jun 2, 2021 · 5 comments

Comments

@icantrank
Copy link

icantrank commented Jun 2, 2021

Problem

When trying to profile all pages on a live site - I get the error 'this page cannot be profiled'.
Inspecting the devtools frame shows errors parsing the json from #liquidProfileData:

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at $jscomp.generator.Engine_.program

I have looked at the response from page?profile_liquid=true and extracted #liquidprofiledata myself, and it parses as json just fine in my ides formatter but not with JSON.parse.
It is 3mb of json / 52k lines formatted. Maybe that has something to do with it? JSON.parse has some hard limits and we have a lot of lines of code.

I saw in another issue that @wizardlyhel asked someone to twitter DM the site to debug further - would be happy to do that if it would help figure out the problem.

@ghost
Copy link

ghost commented Jun 2, 2021

👋 Welcome to the community and thank you for the issue.

@wizardlyhel
Copy link
Contributor

That's a lot of JSON data. I didn't anticipate that we would hit the limits of JSON.parse but I don't think Chrome would get stuck on 3mb of JSON data unless you are in incognito mode. Are you able to identify the area of the string where the syntax error is generated? The error should tell you at what character position it failed at.

@icantrank
Copy link
Author

Hi,

The error is unexpected end of input, aka the JSON ends before a valid close tag so it cannot be parsed.

When i reported this bug I said I had extracted the JSON myself and managed to format it in vs code - today that did not work and the extracted #liquidprofiledata ends suddenly - in the picture below it ends after a "code" property which is never closed, and that is the unexpected end of input.
image

This is the bit of liquid which that line is talking about if that is relevant, it is a bit strange in terms of matching bquotes but it is valid. It automatically minifies those js files everywhere except customiser and preview pages:

    assign assetScripts = 'vendor-scripts-v7.js,theme.js' | split: ','
    assign minify_js = true
    for assetScript in assetScripts
      assign url = assetScript | asset_url 
      unless request.design_mode
        unless content_for_header contains "previewBarInjector.init();"
          if minify_js
            assign url = url | append: '&enable_js_minification=1'
          endif
        endunless
      endunless
      comment 'wrap the script src markup' 
      endcomment
      assign url = '<script src="' | append: url | append: '" defer="defer"></script>'
      echo url
    endfor

I think you are correct that it shouldn't hit hard limits at just 3mb too though. I was just trying to think of what it could be.

Any ideas?

@wizardlyhel
Copy link
Contributor

There is nothing after append: url | append: '\" defer=\"defer\"></script>' inside #liquidprofiledata?

  • Would you check the raw response of the profile_liquid=true and see if the json blob ends there
  • Does profiling works if you remove this piece of code completely?

Not sure how would that be possible to sent an incomplete json blob. Would you also tweet me @wizardlyhel the shop url?

@mgmanzella
Copy link
Contributor

👋 closing as we haven't received the info helen asked for, please re open this issue with that info if this is still a problem

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

No branches or pull requests

3 participants