fix: Fix actionCreator/organization promises and enable no-async-promise-executor
eslint rule
#83270
+35
−41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eslint.org/docs/latest/rules/no-async-promise-executor#rule-details
This rule uncovered a case where an error inside of
loadOrganization()
could result in a stalled sudo auth page, and whereloadTeamsAndProjects()
would swallow errors.loadOrganization
Before: if a
401
or403
response was returned andgetErrorMessage()
couldn't read.detail
or.detail.message
then we'd arrive at the lonelyreturn;
statement on line 178 without resolving or rejecting the parent promise. This would stall the promise forever.Now: the promise always resolves or rejects, one way or another.
This was only a problem inside of:
sentry/static/app/views/organizationContext.tsx
Line 182 in 0944815
Called by:
sentry/static/app/components/modals/sudoModal.tsx
Line 87 in 0944815
All other callsites do no await the promise.
loadTeamsAndProjects
The promise executor inside
loadTeamsAndProjects
had no try/catch blocks before. So any errors thrown from inside any of the function calls (including fetchProjectsAndTeams) would not be caught or re-thown by thenew Promise
class instance. They're just gone, and the promise returned by loadTeamsAndProjects() would never reject.This caused the same issue as
loadOrganization()
above and impacts the same callsites. Now the method always resolves or rejects.