Post Unrecoverably Crashes If Unregistering an In-Use Core Block
Describe the bug If I unregister a core block type has been previously used, the entire post unrecoverably crashes.
To Reproduce
- Create a new post
- Add the Verse alock
- Add code to unregister the verse block (the proper way to do this still isn't documented! see: #11723)
- Reload the post (See error details)
- Disable code to unregister Verse block
- Post is fixed
Here's the JS I'm using to disable the Verse Block:
window.onload = function() {
wp.blocks.unregisterBlockType( 'core/verse' );
};
Error Details

Copy Error results:
value/<@https://myplugins.local/wp-includes/js/dist/editor.min.js?ver=9.0.2:55:115657 value@https://myplugins.local/wp-includes/js/dist/editor.min.js?ver=9.0.2:55:109652 Fd@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:92:365 Mf@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:92:160 ph@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:98:474 eg@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:125:307 fg@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:126:168 wc@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:138:237 gg@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:135:160 Ca@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:133:365 og@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:150:95 Rd@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:150:173 bb.prototype.render@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:200:185 Bc/<@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:153:485 mg@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:148:406 Bc@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:153:420 render@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:202:194 $n@https://myplugins.local/wp-includes/js/dist/edit-post.min.js?ver=3.1.2:12:69103 value@https://myplugins.local/wp-includes/js/dist/editor.min.js?ver=9.0.2:55:271759 Fg@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:154:231 Eg@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:13:419 Hg@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:13:473 ae@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:15:133 Ig@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:155:69 Hc@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:15:416 Jc@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:16:489 gh@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:39:335 lg@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:148:319 re@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:23:322 Xb@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:40:304 ng@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:149:39 Se@https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:40:45
Copy Post Text:
{nothing, doesn't work}
Attempt Recovery: Nothing happens
Console:
TypeError: "x is undefined" value https://myplugins.local/wp-includes/js/dist/editor.min.js?ver=9.0.2:55:115657 value https://myplugins.local/wp-includes/js/dist/editor.min.js?ver=9.0.2:55:109652 Fd https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:92:365 Mf https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:92:160 ph https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:98:474 eg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:125:307 fg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:126:168 wc https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:138:237 fa https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:137:115 lg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:148:342 re https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:23:322 Xb https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:40:304 react-dom.min.js:104:245 TypeError: "x is undefined" value https://myplugins.local/wp-includes/js/dist/editor.min.js?ver=9.0.2:55:115657 value https://myplugins.local/wp-includes/js/dist/editor.min.js?ver=9.0.2:55:109652 Fd https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:92:365 Mf https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:92:160 ph https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:98:474 eg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:125:307 fg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:126:168 wc https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:138:237 gg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:135:160 Ca https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:133:365 og https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:150:95 Rd https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:150:173 render https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:200:185 Bc https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:153:485 mg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:148:406 Bc https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:153:420 render https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:202:194 n https://myplugins.local/wp-includes/js/dist/edit-post.min.js?ver=3.1.2:12:69103 value https://myplugins.local/wp-includes/js/dist/editor.min.js?ver=9.0.2:55:271759 Fg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:154:231 Eg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:13:419 Hg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:13:473 ae https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:15:133 Ig https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:155:69 Hc https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:15:416 Jc https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:16:489 gh https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:39:335 lg https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:148:319 re https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:23:322 Xb https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:40:304 ng https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:149:39 Se https://myplugins.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3:40:45 react-dom.min.js:104:245
Expected behavior Post should display the "block doesn't exist" behavior for third-party blocks:

Desktop (please complete the following information): Win 10, Firefox 63.0.3, 5.0-RC1-43947, Twenty Nineteen, Tiny plugin to deactivate Verse Block and a few others
We tested this during the core editor triage (https://wordpress.slack.com/archives/C02QB2JS7/p1564035774193100 - slack link, requires signup to slack).
I was able to reproduce the issue.
My hunch is that it might be related to the timing of when the block is unregistered. Potentially the editor has already loaded the post and thinks the verse block is available, thus it displays the block without issue. I'm not completely sure when the right time to unregister a block is, would have to look that up.
I still think this is a bug though, so leaving open.
By no means do I think this resolves the issue, but @mcshaman provided a helpful temporary workaround that hides blocks from the Inserter Menus but doesn't actually unregister them, thereby avoiding errors.
This is also causing me issues.
If a block is already present in the content, then you get a fatal error instead of a core/missing block.
Like OP, I am calling unregisterBlockType within a window.wp.domReady callback as per the official documentation.
As above.
Noticing that when I try wp.blocks.unregisterBlockType(blockId) in the web inspector, targetting a block in use, some blocks will disappear from the editor window, and sometimes they remain. In both cases, the function returns the block, indicating it was successfully unregistered.
@mrwweb, I'm no longer able to reproduce the issue.
I noticed that there were errors in the console caused by a new selector, but that will be fixed via #https://github.com/WordPress/gutenberg/pull/43864.
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.
So I was still able to reproduce this. Not if the unregistering happens right on wp.domReady but if it is done after that. Lets say something like
wp.domReady( function() {
setInterval(function() {
unregisterBlockTypes();
}, 200);
});
It also doesn't crash immediately but any further interaction causes a Uncaught (in promise) TypeError: blockType is undefined
The unregistered blocks still show in the block list but with no name

When you focus the instance it disappears

Also you can't save the post because that causes the Uncaught (in promise) TypeError: blockType is undefined error as well.
The problem is that (if I remember correctly) directly running on wp.domReady causes issues with 3rd-party blocks that might only get registered later. So the slight delay may be a quite common pattern.
So this is still broken. The workaround mentioned in https://github.com/WordPress/gutenberg/issues/12484#issuecomment-514915962 still works though.