WordPress: "The editor has encountered an unexpected error"
You open a post or page and the block editor shows a grey box: "The editor has encountered an unexpected error", with the buttons Attempt Recovery, Copy Post Text and Copy Error. A piece of JavaScript in the editor crashed. The cause is almost always a plugin, the theme, a browser extension or a stale cached script, not your post. Here is how to find which, without losing what you wrote.
Click "Copy Post Text" and paste it into a text file. The post is saved in the database and is almost never lost, but this costs nothing.
Click "Copy Error" and paste that too. The first line names the script that crashed, often with a plugin's folder name in it, such as /wp-content/plugins/some-plugin/.
Try "Attempt Recovery". It rebuilds blocks the editor could not read. If the error comes back on every load, the cause is not the post; go on below.
Find the cause, fastest first
Another browser or a private window. If the editor works there, the cause is on your computer: an ad blocker, grammar or password extension, or a stale cache. Clear the browser cache or switch that extension off for your site.
Read the copied error. A plugin's folder name in it is your answer. Update that plugin, or deactivate it and reload the editor.
Clear every cache. A caching or "optimise JavaScript" plugin, the host's cache and Cloudflare can serve an old editor script after a WordPress update. Purge them all, then reload with Ctrl+F5.
Plugins one by one. Deactivate all plugins (or use the Health Check plugin's Troubleshooting mode, which does this only for you, not your visitors), then switch them back on one at a time and reload the editor each time. The one that brings the error back is the cause.
The theme. If all plugins are off and it still fails, switch to a default theme such as Twenty Twenty-Four for a minute. A theme that adds its own editor scripts can crash the editor after a WordPress update.
Only one post fails. A single block in it is broken, often from a plugin you removed. Open the post with the Code editor (the three-dot menu, Code editor), find the block whose plugin is gone, and remove or convert it.
What you see, what it means, what it needs
What you see
What it means
Usual fix
Error in one browser only
A browser extension or cached script
Clear cache, switch the extension off for the site
Copied error names a plugin folder
That plugin's editor script crashed
Update or deactivate that plugin
Started right after a WordPress update
A plugin, theme or cache is out of step
Purge caches, update plugins and theme
Every post fails, every browser
A plugin or the theme
Plugins one by one, then a default theme
Only one post fails
One broken block in that post
Code editor, remove or convert that block
What not to do
Do not delete and rewrite the post. The content is in the database; the editor is what broke.
Do not install the Classic Editor plugin as the fix and stop there. It hides the crash, and the plugin that caused it may break something visitors see next.
Do not deactivate plugins on a busy shop during opening hours without Troubleshooting mode; visitors see the site change too.
Do not roll WordPress back to an old version. Update the plugin or theme that is behind instead.