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: Add error handle to the 'registry.batch' method #62322

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/data/src/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,14 @@ export function createRegistry( storeConfigs = {}, parent = null ) {

emitter.pause();
Object.values( stores ).forEach( ( store ) => store.emitter.pause() );
callback();
emitter.resume();
Object.values( stores ).forEach( ( store ) => store.emitter.resume() );
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also wrap with try/catch/finally the callback() that we run if we're already batching above (L319)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L319 returns early and doesn't touch emitters. Bubbling the errors should be okay there.

callback();
} finally {
emitter.resume();
Object.values( stores ).forEach( ( store ) =>
store.emitter.resume()
);
}
Mamaduka marked this conversation as resolved.
Show resolved Hide resolved
}

let registry = {
Expand Down
Loading