wp.data.select( store ).getEntityRecords seems to be hiding all errors. Is this a bug?
#79376
-
|
I noticed that when using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Not really a bug in the sense of "broken code," it's an intentional (if incomplete) workaround, and the WordPress team has openly flagged it as a known limitation right in the source comments. The } catch ( error ) {
// We need a way to handle and access REST API errors in state
// Until then, catching the error ensures the resolver is marked as resolved.
} finally {
dispatch.__unstableReleaseStoreLock( lock );
}
So the empty catch block isn't an oversight, it's there on purpose to guarantee resolution completes. The tradeoff is exactly what you noticed: the error itself goes nowhere. It isn't stored, it isn't rethrown, it's just discarded after letting the resolver finish. A relevant detail: core data does have error tracking selectors for writes, So to directly answer your question... this looks like a known, acknowledged tradeoff rather than an accidental bug, based on the resolver source and the PR that introduced this behavior ( |
Beta Was this translation helpful? Give feedback.
Not really a bug in the sense of "broken code," it's an intentional (if incomplete) workaround, and the WordPress team has openly flagged it as a known limitation right in the source comments.
The
getEntityRecordresolver (singular) has had this exact pattern for years:getEntityRecords(plural, what you're using) didn't originally have this catch at all, which actually caused a worse problem: if the REST call failed, the resolver would throw, andisResolving()/