diff --git a/src/libs/actions/OnyxUpdateManager/index.ts b/src/libs/actions/OnyxUpdateManager/index.ts index 2a7081009ea3..4bef25f9e8a3 100644 --- a/src/libs/actions/OnyxUpdateManager/index.ts +++ b/src/libs/actions/OnyxUpdateManager/index.ts @@ -154,6 +154,13 @@ function handleMissingOnyxUpdates(onyxUpdatesFromServer: O // we don't have base state of the app (reports, policies, etc.) setup. If we apply this update, // we'll only have them overwritten by the openApp response. So let's skip it and return. if (isLoadingApp) { + // If one of these onyx updates is for the authToken, update it now because our current authToken is probably invalid. + updateAuthTokenIfNecessary(onyxUpdatesFromServer); + + // Nothing reads this key again once we return, but it is persisted, so a restart would replay it and + // could write a now-stale authToken over a newer session. Drop the consumed copy. + Onyx.set(ONYXKEYS.ONYX_UPDATES_FROM_SERVER, null); + // When ONYX_UPDATES_FROM_SERVER is set, we pause the queue. Let's unpause // it so the app is not stuck forever without processing requests. unpauseSequentialQueue();