-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Core Data: Resolve getCurrentUser on API error #38989
Conversation
Would #38669 fix it as well? If we merge both, the error details will be lost. |
Size Change: +5 B (0%) Total Size: 1.15 MB
ℹ️ View Unchanged
|
Good point, @adamziel. I wondered if we should remove the current user from the store if the API request fails. Can we trust previously determined |
Oh that's a great question. There are two aspects that comes to mind:
I believe the backend authentication already takes care of the former, so we're only talking about the UI aspects. And in this case... it's quite a complex thing. For example, maybe the error is a temporary network issue? Then maybe we're still logged in as the same user. But perhaps it's an Unauthorized error? Then yes, it makes sense to remove the But if we're logged out, then most other requests would fail, too, so how do we handle that? By the way, we could make the same case for many resolvers. For example, if an entity record is being re-requested but turns out to be missing, it would make sense to remove it from the state and ensure it is somehow communicated to the user. But maybe it was just a packet gone missing and we're good to just silently retry the request? All in all, it sounds like a larger discussion to have about handling different ways in which the requests may fail in different contexts. cc @gziolo @jsnajdr @youknowriad |
Thanks, @adamziel. I agree this sounds like a part of the larger discussion. |
@adamziel, fantastic work on that PR 🦸 Do you have cases to use new meta selectors in the core? Then I can use it as an example to resolve this issue. |
@Mamaduka I think it haven't looked into how the selectors could be used across the Gutenberg yet, but there's one example from @getdave's that leans on the fact that resolveSelect throws an error: The #38669 will mark the resolver as "finalized", but there's still a matter of doing something with the error. I'm not too convinced about using |
Description
See #37682.
Add
try/catch
togetCurrentUser
. Even if we do nothing, catching an error ensures the resolver is marked as resolved.Testing Instructions
I couldn't figure out how to test this manually, so I included unit tests.
Types of changes
Bugfix
Checklist:
*.native.js
files for terms that need renaming or removal).