Skip to content

Crash occurs when state.preferences does not include insertUsage. #14580

@herregroen

Description

@herregroen

Describe the bug
If the preferences of a user saved in localstorage ( key WP_DATA_USER_${USER_ID} ) includes an empty object ( { 'core/editor': { preferences: {} } ) this will cause the entire editor to crash when the getInsertUsage selector is used. Which is automatically within several seconds after starting when getInserterItems is called.

I've run into this issue on two separate installations now running WordPress 5.1.1 without the Gutenberg plugin installed. I've not yet found what exactly is causing preferences to be saved as an empty object but I believe it's likely related to https://github.com/WordPress/gutenberg/blob/master/packages/data/src/plugins/persistence/index.js#L210 as insertUsage is explicitly omitted there.

To Reproduce
Steps to reproduce the behavior:

  1. Somehow get a localStorage where under WP_DATA_USER_${USER_ID} the core/editor object and then preferences object does not include an insertUsage key.
  2. Open Gutenberg.
  3. Wait several seconds or call wp.data.select( 'core/editor' ).getInserterItems()
  4. See error

Expected behavior
Gutenberg not to crash and invalid values in localStorage to either be fixed or discarded.

Screenshots
Screenshot 2019-03-22 at 16 09 44

Desktop (please complete the following information):

  • OS: iOS
  • Browser chrome
  • Version 72.0.3626.121

Metadata

Metadata

Assignees

Labels

[Priority] HighUsed to indicate top priority items that need quick attention[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions