fix: ignore "not found in store" race on boot in getCalendarDetailAsync.rejected
On hard reload, useCalendarLoader dispatches getCalendarDetailAsync(calId) for selected calendars (cached in localStorage) BEFORE getCalendarsListAsync has fulfilled. The detail thunk sees an empty state.calendars.list and rejects with "Calendar X not found in store". The reject handler then sets state.calendars.error, and HandleLogin redirects to /error. Result: ~50% of reloads land on /error. Treat this specific race-condition error like AbortError: ignore it. The detail fetch is naturally re-issued by useCalendarLoader once the list is loaded, so no functional regression.
This commit is contained in:
@@ -433,8 +433,13 @@ const CalendarSlice = createSlice({
|
|||||||
state.pending = false
|
state.pending = false
|
||||||
if (
|
if (
|
||||||
action.payload?.message.includes('aborted') ||
|
action.payload?.message.includes('aborted') ||
|
||||||
action.error.name === 'AbortError'
|
action.error.name === 'AbortError' ||
|
||||||
|
action.payload?.message?.includes('not found in store')
|
||||||
) {
|
) {
|
||||||
|
// "not found in store" is a boot race condition: useCalendarLoader
|
||||||
|
// dispatches getCalendarDetailAsync for cached selected calendars
|
||||||
|
// before getCalendarsListAsync has fulfilled. Safe to ignore — the
|
||||||
|
// detail fetch will be re-issued once the list is loaded.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
state.error =
|
state.error =
|
||||||
|
|||||||
Reference in New Issue
Block a user