Automattic / wp-calypso

The JavaScript and API powered WordPress.com
https://developer.wordpress.com
GNU General Public License v2.0
12.42k stars 1.99k forks source link

Atomic: Editor error "Updating failed. The response is not a valid JSON response" when publishing posts and pages #40574

Closed pauljacobson closed 4 years ago

pauljacobson commented 4 years ago

Users on a WordPress.com Business plan have reported encountering the following error when attempting to publish posts and pages through Calypso:

Updating failed. The response is not a valid JSON response.

As the original Happiness Engineer who reported the issue explained:

In this case, the post/page edits are not saved in a revision, and the changes must be copied/pasted manually in order to be saved.

This issue seems to occur when a user starts working on a post or page, and then steps away for a period of time. The issue doesn't seem to be readily reproducible, so it's tricky to troubleshoot.

This issue has been reported here too: Updating failed. Error message: The response is not a valid JSON response - Centos 7 · Issue #18783 · WordPress/gutenberg.

This issue is for added visibility, as suggested here: p1585558290023800-slack-C02FMH4G8 (the link to the expanded, internal report is in that discussion thread).

Context / Source

Multiple user reports over the course of several months.

samiff commented 4 years ago

19845402-hc

lancewillett commented 4 years ago

If this is only happening to 1 or 2 sites, we should log to the Happiness Feedback P2 or Atomic Requests P2 to troubleshoot things like some of the post or page content flagging a security warning.

The Gutenberg core fix would like likely be a more friendly error message.

lancewillett commented 4 years ago

Tracking added by @noahtallen in https://github.com/Automattic/wp-calypso/pull/40035

sophiegyo commented 4 years ago

Just commenting that we had another report in 2912227-zen. I did mention it in the P2 post where it's being tracked, but figured it was worth noting here too. The site in question doesn't have a lot of plugins, only our own and one social media icons plugin.

donalirl commented 4 years ago

I've been able to recreate this somewhat consistently: it tends to happen when you have the editor open in multiple tabs/windows on your browser. I discovered it while batch-editing a bunch of posts on a personal site and it came up in two other cases here:

21438861-hc

21447362-hc

In all cases, closing all additional tabs/windows and refreshing the page of the one tab you are editing in will fix it. Hope this helps!

davemart-in commented 4 years ago

Let's get this one on the radar of the newly formed Gutenberg Platform Squad. cc @sirreal

noahtallen commented 4 years ago

linking this too with more debug info: p9F6qB-4PJ-p2

Addison-Stavlo commented 4 years ago

I have been exploring trying to reproduce this error. So far it seems to be specific to "Business" and "eCommerce" plans that have undergone the 'Automated Transfer' (AT) process. Jetpack'd atomic ephemeral sites and others do not seem to have the issue. 🤔

I can consistently reproduce the issue on those sites following these steps:

Screen Shot 2020-07-07 at 2 12 44 PM

I am also able to reproduce this with only 1 instance of the editor open, however a bit less consistently:

Screen Shot 2020-07-07 at 2 25 36 PM

I believe this may be stemming from the same root cause.

andrewserong commented 4 years ago

Thanks @Addison-Stavlo that's super helpful, I can replicate those first steps now. I'll do some more digging!

kevin940726 commented 4 years ago

Have a user experiencing this issue today: 22862652-hc. Did a browser refresh and the issue was gone.

+--------------------+----------+-----------+---------+
| name               | status   | update    | version |
+--------------------+----------+-----------+---------+
| akismet            | active   | none      | 4.1.6   |
| amp                | active   | none      | 1.5.5   |
| classic-editor     | inactive | none      | 1.5     |
| coblocks           | active   | none      | 2.1.0   |
| full-site-editing  | active   | none      | 1.14    |
| gutenberg          | active   | available | 8.3.0   |
| jetpack            | active   | none      | 8.7.1   |
| layout-grid        | active   | none      | 1.2.4   |
| page-optimize      | active   | none      | 0.5.0   |
| pretty-link        | active   | none      | 3.1.1   |
| wpcomsh-loader     | must-use | none      |         |
| advanced-cache.php | dropin   | none      |         |
| object-cache.php   | dropin   | none      |         |
+--------------------+----------+-----------+---------+
thebud15 commented 4 years ago

We didn't do a plugin conflict test during the chat (as I recommended the copy/paste workaround, but noting this case here

22817770-hc

scosgro commented 4 years ago

Another one in #23143308-hc. Plugins (same error with Gutenberg activated):

+--------------------+----------+-----------+---------+ | name | status | update | version | +--------------------+----------+-----------+---------+ | akismet | active | none | 4.1.6 | | amp | active | none | 1.5.5 | | classic-editor | inactive | none | 1.5 | | coblocks | active | none | 2.1.0 | | full-site-editing | active | none | 1.14 | | gutenberg | inactive | available | 8.3.0 | | jetpack | active | none | 8.8 | | layout-grid | active | none | 1.2.4 | | page-optimize | active | none | 0.5.0 | | wordpress-seo | active | none | 14.6.1 | | wpcomsh-loader | must-use | none | | | advanced-cache.php | dropin | none | | | object-cache.php | dropin | none | | +--------------------+----------+-----------+---------+

PHP-Errors [03-Aug-2020 20:30:35 UTC] PHP Warning: json_decode() expects parameter 1 to be string, array given in /wordpress/plugins/wpcomsh/2.4.128/wpcomsh.php on line 1067

User said it only showed up in Safari, and no amount of browser diagnostics could remove it. Everything works fine in Chrome.

rickmgithub commented 4 years ago

23456032-hc

Copied page code to another post to save their page content. After coming out of the original post the editor worked fine again.

chrisfromthelc commented 4 years ago

23612981-hc

This user has had the issue before and ticks the "too many copies of the same page" and "leaving open too long" boxes.

roo2 commented 4 years ago

Some things I've noticed so far: Yea, this is hard to debug without being able to reproduce it on ephemeral sites, simple sites, or simulating the api call that's being made 🤔 but Addie's repro instructions work consistently👍.

noahtallen commented 4 years ago

When the "editing toolkit" is disabled, the page autosaves successfully

That's definitely an interesting find :thinking:

roo2 commented 4 years ago

on second thought, it looks like that was a red herring, I'm not sure why I stopped being able to reproduce the bug when I deactivated the plugin.... but then I re-activated it and still couldn't reproduce the bug... the joys of this kind of debugging, hmmm I almost wonder if I've found a support workaround that I don't understand yet 😂

noahtallen commented 4 years ago

ahh weird!

marutim commented 4 years ago

Another report here: 23659379-hc

As a workaround, the user was able to create a new post from the wp-admin dashboard

Addison-Stavlo commented 4 years ago

on second thought, it looks like that was a red herring, I'm not sure why I stopped being able to reproduce the bug when I deactivated the plugin.... but then I re-activated it and still couldn't reproduce the bug... the joys of this kind of debugging

I know this pain all too well and sympathize with the frustration. 😭 🙃

roo2 commented 4 years ago

hmm I got very stuck on this and was no longer able to reproduce it on my test site or my other test site or even a new atomic site 🤔 did this issue just fix itself with a gutenberg update or something?

Also, I've been thinking about this at a higher level. When a user is in this situation with two editors open, they are actually already set up for failure. Whether that is lost updates or potential unhandled cases like this, I think that a better approach would be to attempt to discourage users from using two editors at the same time pbxlJb-ms-p2

roo2 commented 4 years ago

also, this is the P2 thread where this was originally reported for more context/cases p9F6qB-4PJ-p2. I tried again to reproduce this and still can't get it to manifest itself any more

supernovia commented 4 years ago

Noting we see this with some frequency in the forums (not often tagged consistently but there's this). I'm not sure about the JSON thing. What we see is that the auto save has failed and kinda hung up. People see a similar issue with saving drafts.

I experienced it once myself after stepping away for a bit. Had to copy my work and hard refresh, then paste again before I could save.

sirreal commented 4 years ago

I experienced it once myself after stepping away for a bit.

Oh, that's a nice observation. Do we get this response if the nonce is expired or otherwise invalid?

alshakero commented 4 years ago

Hi @roo2! I assigned myself to this issue if that's OK. Please LMK if you're working on it.

roo2 commented 4 years ago

Hi @roo2! I assigned myself to this issue if that's OK. Please LMK if you're working on it. @alshakero

No, I really gave up on reproducing this and was looking to move forward changing how we handle two editors open at the same time instead. I hope you can make some progress on it! pbxlJb-ms-p2

alshakero commented 4 years ago

This was a mean issue. Fix and explanation are ready here 🎉

fullofcaffeine commented 4 years ago

I have been exploring trying to reproduce this error. So far it seems to be specific to "Business" and "eCommerce" plans that have undergone the 'Automated Transfer' (AT) process. Jetpack'd atomic ephemeral sites and others do not seem to have the issue. thinking

I can consistently reproduce the issue on those sites following these steps:

* Open a post in WP Admin & make small edit. Don’t save; leave tab open.

* Switch to Calypso and open same post. Make edits and update post.

* Switch back to WP Admin tab. JSON message has already appeared, presumably because auto save failed after the post was updated in Calypso. (may need to wait a minute, or even try hitting the 'Update' button)

* The 403 error is observable both with auto-saves and trying to update manually from there:

Screen Shot 2020-07-07 at 2 12 44 PM

I am also able to reproduce this with only 1 instance of the editor open, however a bit less consistently:

* Navigate to wp-admin in either the pages or posts management page.  Do not load the editor.

* In a separate tab: open calypso, navigate to your site, and open the editor for a page or post.

* Tab back to wp-admin, checkbox a post, select the bulk action to 'trash' and 'apply'

* Notice you are redirected to a 403 Screen.

Screen Shot 2020-07-07 at 2 25 36 PM

I believe this may be stemming from the same root cause.

Thanks a lot for investigating how to reproduce this issue, Addison! And thanks Omar for the fix! ❤️

I just tried with Gutenberg 9.0 on Atomic and could reproduce it. I then tried with 9.1.1 and the issue didn't happen, then repeated the whole process, same results.

I'll close this issue, but feel free to re-open it if we find out this is still an issue.

noahtallen commented 4 years ago

Wonderful! I want to mention that the error The response is not a valid JSON response can occur for several reasons. It looks like we've fixed the most common one which caused customers to report it on WordPress.com. But I want to mention that it is possible that we may see some intermittent reports of the issue which have different causes.

marutim commented 3 years ago

I had a user in the chat with this issue. Ref: 26847932-hc

The message could be replicated on all the pages on update. Good news is that it does not really stop the update but the notice keep appearing. Here is a link to the video to help test it: https://d.pr/v/eZb6Xt

Steps I tried to fix the behavior:

None of the above helped.

We had a discussion on this issue in the slack here: p1610098879495100-slack-C03TY6J1A

@noahtallen I am not re-opening the issue while adding this comment but tagging you so that you can take a look and take the necessary steps.

Feel free to let me know if I can help.

geekinthegirl commented 3 years ago

I've had a user in chat with this issue today too: 26801089-hc

The 'Update failed. The response is not a valid JSON response' message was replicated on all of their existing posts and pages, whenever they tried to use the editor or make any changes.

I suggested:

Thanks!

edwinho89 commented 3 years ago

Another issue reported in 26446143-hc

It is unclear what is the root cause (previous workaround above did not help)

However, a quick plugin dance by deactivating all plugins, and reactivating them again addressed the issue.

happychait commented 2 years ago

Another customer reported this in 33120735-hc

cintacks commented 2 years ago

Another customer reported this in 34780051-hc. I know this is closed but for logging sake am adding it here.

I was able to reproduce by adding the Blog Posts Block (on multiple posts), and trying to Update said post.

Workaround: used the Query Loop Block and recreated a Blog Posts loop manually.

filipanoscampos commented 2 years ago

The user on this ticket is also having this issue (4877980-zd-woothemes and 34780051-hc) and came back to us to share the issue persists. They added "even when the blog was published, nothing would display, same as when it wasn’t published. If I tried to update it, it would throw a JSON error and not publish or update anything."

They have had this issue for a while, The Blog page is now in the trash, so I asked the user if we could try to restore it.

desnum commented 2 years ago

Another case in 34570476-hc

github-actions[bot] commented 1 year ago

Support References

This comment is automatically generated. Please do not edit it.

sophiegyo commented 1 year ago

Another instance in 6667487-zen but that could also be due to the user's custom plugin - they're trying to insert a shortcode and that seems to be when the error comes up.