json-viewer icon indicating copy to clipboard operation
json-viewer copied to clipboard

Failed to load CSS

Open HomenSimpsor opened this issue 11 years ago • 9 comments

The stylesheet doesn't load anymore. Any ideas?

image

HomenSimpsor avatar Jun 22 '15 11:06 HomenSimpsor

Hi @Wideshanks, I will look this today. Could you try to disable/enable the extension again e see if it works (temporarily)? My chrome version is Version 43.0.2357.124 (64-bit), what is yours?

tulios avatar Jun 22 '15 11:06 tulios

I just notice that the response is an error, I will check this. I believe that it is failing on error responses, I will try to fix it asap.

tulios avatar Jun 22 '15 11:06 tulios

Errors have anything to do with this bug. I'll keep checking.

tulios avatar Jun 22 '15 12:06 tulios

I see the new 0.9.0, with the change to MAX_WAIT, but I still have the same behavior.

So I start with a new Chrome profile, only json-viewer 0.9.0 is installed:

image

Chrome version:

image

I have the same error as before, but it now takes around 10 seconds for the JSON output to load, still without CSS.

image

(The example used this time is a successful response, unlike the Facebook github endpoint above.)

The timeline in the image isn't easy to follow, but it's pausing for around 10 seconds and then paints the response on the screen

Network tab shows the document request itself finishing in 500ms.

image

You can see I also get a 200 response on viewer.css. The URL of the CSS mentioned in the error message in the console is valid and I can access it:

image

The CSS data is valid and passes csslint.

The stack trace points to this line in load-css.js, in the if (attempts > MAX_WAIT):

image

It looks like the content var here being compared to loaded or 'loaded':

image

--ends up being an empty string:

image

HomenSimpsor avatar Jun 26 '15 13:06 HomenSimpsor

Hi @Wideshanks thanks for this great analysis, I will reopen the issue and try to reproduce this bug again

tulios avatar Jun 26 '15 14:06 tulios

Hey @Wideshanks I finally found the problem, I will release 0.9.1 version. Thanks for your support and patience.

tulios avatar Jun 26 '15 14:06 tulios

Well, you replied before I could send this, but here you go anyway:

Spoke too soon. The version above was paused in the debugger on the first loop. The content is empty only for the first attempt (probably the reason you had a loop there to begin with).

If I directly modify the source of the extension to log content:

image

It's empty only on the first try, subsequent checks have it as "loaded"

image

So, the check is for single-quotes 'loaded', but my content var is showing double-quotes "loaded". If I change that check, the CSS loads:

image

Also, I would avoid comparing the number of attempts with a number of milliseconds in MAX_WAIT because the intended 2 second MAX_WAIT may not be 2 seconds, it'll be 2,000 attempts.

image

I see that each of the attempts has a setTimeout interval of 1ms, but on my machine at least, it takes way longer than 1ms.

HomenSimpsor avatar Jun 26 '15 14:06 HomenSimpsor

picture

Thanks again, 0.9.1 rolling out

tulios avatar Jun 26 '15 14:06 tulios

@Wideshanks about the MAX_WAIT I agree with you, the intention was to be a number of times, the comment I added about the seconds was wrong, I reverted to 20 attempts and I will change the name of this constant.

tulios avatar Jun 26 '15 14:06 tulios