Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Error loading block: The response is not a valid JSON response. #511

Closed
DavidMillington-CD opened this issue Jan 29, 2020 · 3 comments
Closed

Comments

@DavidMillington-CD
Copy link

DavidMillington-CD commented Jan 29, 2020

Bug summary

If you enter too much text into a Rich Text field then when you click off the block you will see a grey block instead of the content with the error message:

Error loading block: The response is not a valid JSON response.
https://imgur.com/KY7YTpn

That is a pretty generic Gutenberg error which a quick google search shows los of people have for what appears to be a wide variety of reasons. I suspect a good chunk of those are for the same reason I am detailing here. I don't believe there is anything you can do about this beside forcing a max character limit internally but I am unsure of what the limit should be. I explain why that is below.

I added this as a bug ticket mainly to get it into the system in case anybody else ran into the problem so they could see a possible solution e.g. reduce the amount of text in the field or split it into multiple fields/blocks.

Steps to reproduce

  1. Create new Block with a Rich Text field
  2. Place that Block on a new page
  3. Copy and paste a lot of text into it

An example of it breaking is to enter 8050 characters. I used this site to generate a single string of that length: http://www.unit-conversion.info/texttools/random-string-generator/ and I see the error. If I delete 1 character so the length is 8049 then the Block preview works.

This was actually identified on a client site where they had dumped a ton of text into the Rich Text field that they copy and pasted from their old site. Strangely with that the number of characters that broke the preview was 5899. If I chopped it down to 5898 then it works.

Edit: Also had it with another Block with 4026 characters in it. Tried chopping 20 characters off and it was still showing the error. Didn't have time to investigate that one further as I have 50+ other pages to check and "fix".

It would be great if someone could explain the difference so I could pass that along to the client.

In my testing this only affects the Block preview box. The full text is saved and loaded. If you click the Block to edit it then you do see the full text and there are no errors when saving, besides the grey preview box error. All the text is displayed successfully on the front end.

@DavidMillington-CD
Copy link
Author

DavidMillington-CD commented Jan 29, 2020

Just found another area with the problem. This time it's the client mis-using a repeater block. We didn't set an upper limit on it so they have added 25 items. The repeated items are not complex, essentially it's 2 titles and 2 Rich Text boxes for a 2 column layout. Each only has one or two fairly short paragraphs. The problem is the same as in my first post, grey block saying there was an "Error loading block". Editing works and the data is displayed on the front end.

My two guesses are either (a) too much data is being returned for the Preview to display or (b) there is some sort of vertical limit to what can be visually displayed in a block preview. I'm leaning towards the later since the character limit seemed variable based on tests I mentioned in my first post.

@lukecarbis
Copy link
Member

Thanks for reporting this @DavidMillington-CD . We're aware of the issue and are tracking it over here: #436.

@kienstra
Copy link
Collaborator

kienstra commented Apr 4, 2020

Hi @DavidMillington-CD,
Sorry it's taken so long, and hope you're doing well.

If you're still interested, could you please test a fix for the issue?

#524 (comment)

Thanks, and have a great weekend.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants