Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data: Stores become unresponsive when batched actions trigger an error #62311

Closed
Mr2P opened this issue Jun 5, 2024 · 5 comments · Fixed by #62322 or #62346
Closed

Data: Stores become unresponsive when batched actions trigger an error #62311

Mr2P opened this issue Jun 5, 2024 · 5 comments · Fixed by #62322 or #62346
Assignees
Labels
[Package] Data /packages/data [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@Mr2P
Copy link

Mr2P commented Jun 5, 2024

Description

Possible solution: change from catch statement to finally statement in this line https://github.com/WordPress/gutenberg/blob/trunk/packages/core-data/src/resolvers.js#L298

Step-by-step reproduction instructions

Execute useEntityRecords('root', 'site') inside the edit function of a block.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.6 beta 1
Twenty-Twenty Four
Chrome
Desktop with Windows 11

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Mr2P Mr2P added the [Type] Bug An existing feature does not function as intended label Jun 5, 2024
@Mamaduka Mamaduka added Needs Testing Needs further testing to be confirmed. [Package] Core data /packages/core-data labels Jun 5, 2024
@Mamaduka
Copy link
Member

Mamaduka commented Jun 5, 2024

Thanks for reporting the issue, @Mr2P!

Can you provide more details for the reproduction steps? What should I test after placing useEntityRecords in the block edit component?

Update: I was able to reproduce the issue.

Note: The site entity doesn't support fetching a list of entities (getEntityRecord), so you should use the useEntityRecord hook for it.

@Mamaduka Mamaduka removed the Needs Testing Needs further testing to be confirmed. label Jun 5, 2024
@Mr2P
Copy link
Author

Mr2P commented Jun 5, 2024

@Mamaduka In my block, I need to fetch all public setting fields as follows:
const { records, isResolving } = useEntityRecords( "root", "site", { per_page: -1 }, );
It worked well before this commit getEntityRecords: batch actions in Gutenberg version 18.2.0. Someone changed from finally to catch caused this issue. I’m not sure why it was changed to catch, but I believe that reverting it back to finally will resolve the issue.”

@Mamaduka
Copy link
Member

Mamaduka commented Jun 5, 2024

@Mr2P, the site has only a single entity with settings provided as its properties and no pagination. Using useEntityRecord( 'root', 'site' ) should give you the same results.

#60591 indeed introduced the behavior change, but it is not a cause of the bug; it only highlighted one.

There are two issues:

  1. Calling getEntityRecords( 'root', site' ) will throw an error. Because it doesn't return an entity list (Related getEntityRecords returns empty list for custom endpoint #61348).
  2. registry.batch lacks error handling. It will pause store emitters, but they're never resumed due to error.

cc @ellatrix, @jsnajdr, @youknowriad

@Mamaduka Mamaduka changed the title Calling useEntityRecords('root', 'site') locks the whole UI of the page in the Gutenberg plugin starting from version 18.2.0 and in WP 6.6 beta 1 Data: Stores become unresponsive when batched actions trigger an error Jun 5, 2024
@Mamaduka Mamaduka added [Package] Data /packages/data and removed [Package] Core data /packages/core-data labels Jun 5, 2024
@Mr2P
Copy link
Author

Mr2P commented Jun 5, 2024

@Mr2P, the site has only a single entity with settings provided as its properties and no pagination. Using useEntityRecord( 'root', 'site' ) should give you the same results.

@Mamaduka Thank you for this information.

@Mamaduka
Copy link
Member

Mamaduka commented Jun 5, 2024

@Mr2P, the main issue should be resolved via #62322.

I'm going to re-open the issue since it's important to resolve reducer warnings caused by the selector getEntityRecords( 'root', site' ) call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Data /packages/data [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
2 participants