Slow store cannot run profiler on any page
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.
👋 Welcome to the community and thank you for the issue.
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.
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.

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?
There is nothing after append: url | append: '\" defer=\"defer\"></script>' inside #liquidprofiledata?
- Would you check the raw response of the
profile_liquid=trueand 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?