Skip to content

[Due for payment 2026-10-26] [$175] [Android] "Update Required" shown after updating the app because the startup ReconnectApp prefetch sends the old appversion #103764

Closed

Description

@VickyStash

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.5-2 (installed), previous session on 9.4.89-0
Reproducible in staging?: N/A
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: N/A
Email or phone of affected tester (no customers): N/A
Logs: See below
Expensify/Expensify Issue URL: N/A
Issue reported by: Customer report
Slack conversation (hyperlinked to channel name): N/A

Action Performed:

The issue was reported by the user. Not reproduced yet.

  1. On Android, use the app on a version that is now below the server's minimum (e.g. 9.4.89-0, minimum is 9.5.1). This makes the app save its ReconnectApp request for the next launch.
  2. Close the app.
  3. Update the app from the Play Store to a version at or above the minimum (e.g. 9.5.5-2).
  4. Open the app.

Expected Result:

The app opens normally. The installed version is above the minimum.

Actual Result:

The app shows the "Update Required" screen and can't be used, even though the installed version is current.

Workaround:

N/A

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

N/A

Root cause

On native, ReconnectApp is prefetched at startup with react-native-nitro-fetch: each JS ReconnectApp call saves its full request body for the next launch. That body comes from enhanceParameters, so it contains appversion from the build that saved it.

After an app update, the first launch sends that saved body before JS loads. It carries the previous build's appversion, so the server returns 426 Deprecated app version. The new JS bundle's own ReconnectApp is then answered from that cached response instead of going to the server. HttpUtils sees jsonCode: 426, calls alertUser(), and the app shows Update Required page.

What the logs show

One affected session, all within ~1 second of app launch:

Command appversion Result
ReconnectApp (prefetched) 9.4.89-0 426
OpenHomePage, Search, GetRules, Log 9.5.5-2 200

Server log for the ReconnectApp request:

[ForceAppUpgrade] Comparing app version to minimum ~~ appVersion: '9.4.89-0' minimum: '9.5.1' needsUpgrade: '1'
Deprecated app version detected - forcing the user to upgrade
Profile ~~ {"cmd":"ReconnectApp","jsonCode":426}

Only ReconnectApp carried the old version. It also carried an older clientUpdateID than the requests that followed, which fits a request body saved in an earlier session.

How the code produces it

  1. ReconnectApp is the only command prefetched on native. src/libs/Prefetch/PrefetchQueries/index.native.ts:6
  2. Request.ts calls enhanceParameters, which adds appversion: pkg.version to the request body. src/libs/Request.ts:26, src/libs/Network/enhanceParameters.ts:73
  3. processHTTPRequest saves that body for the next launch with registerPrefetchOnAppStart, which calls prefetchOnAppStart(url, fetchParams). src/libs/HttpUtils.ts:94-107
  4. At the next launch, nitro-fetch sends the saved body unchanged and adds only token headers. react-native-nitro-fetch/android/.../AutoPrefetcher.kt:141-172, 223-232
  5. The JS request with the same prefetchKey gets the pending or cached prefetch response. react-native-nitro-fetch/android/.../HybridNitroFetchClient.kt:502-521
  6. The 426 calls alertUser(), which sets RAM_ONLY_UPDATE_REQUIRED and renders UpdateRequiredView.src/libs/HttpUtils.ts:242-244, src/libs/actions/UpdateRequired/index.native.ts:6, src/Expensify.tsx:295-296

The startup token-refresh body already avoids this problem. buildAuthenticateBody leaves appversion out on purpose:

// The `appversion` parameter is omitted intentionally here.
// This is because it can cause issues during app updates and
// it is not needed by the "Authenticate" command for token refresh.
// eslint-disable-next-line @typescript-eslint/naming-convention
const {referer, platform, api_setCookie, isFromDevEnv} = getBaseRequestParameters();

That only covers the Authenticate body. The saved ReconnectApp body is the JS request's FormData and still includes appversion.

Proposed solutions

  1. Remove appversion from the saved ReconnectApp body, as buildAuthenticateBody already does for Authenticate.
  2. Clear saved prefetches when the app version changes: store the version that saved them and call removeAllFromAutoprefetch() at startup if it doesn't match pkg.version.

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit

Activity

  1. added
    Daily
    Bug
    on Oct 12, 2026
  2. MelvinBot commented on Oct 12, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    I checked the code, and the root cause in the issue holds. On every JS ReconnectApp call, registerPrefetchOnAppStart saves the request's full FormData to the nitro-fetch startup queue. That body includes the appversion that enhanceParameters added.

    After an update, the native side resends that saved body before JS loads. It only swaps in a fresh authToken, so the old appversion goes out and the server returns 426. The new JS ReconnectApp uses the same key, ReconnectApp:<accountID>, so it receives that 426. Then HttpUtils calls alertUser().

    Only Authenticate was fixed for this. buildAuthenticateBody leaves out appversion, but the saved ReconnectApp body still includes it.

    What changes do you think we should make in order to solve the problem?

    In registerPrefetchOnAppStart, remove appversion from the saved copy of the body before calling prefetchOnAppStart:

    1. Build a new FormData from fetchParams.body.getParts(), skipping the appversion field.
    2. Pass {...fetchParams, body: strippedBody} to prefetchOnAppStart.

    The live JS request at HttpUtils.ts:118 still sends appversion, so the server still enforces the minimum version on every normal request. This follows the approach already used for Authenticate.

    Add a unit test: register a ReconnectApp prefetch and assert the saved body has no appversion while its other fields stay unchanged.

    What alternative solutions did you explore? (Optional)

    • Add pkg.version to the prefetch key in preparePrefetchRequest and clear entries saved under old keys. A response requested by an old build then never reaches a new build. The cost is no prefetch benefit on the first launch after each update.
    • Clear the queue from JS when the version changes (solution 2 in the issue). This doesn't protect the launch that shows the bug. The native request is already sent before JS runs, and removeAllFromAutoprefetch clears only the saved queue, not the pending or cached response. A real fix this way needs a native patch to nitro-fetch.
    Investigation details
    • Timing: JS only gets the stale response if the native prefetch is still running, or finished less than 5 seconds earlier (nitro-fetch's default cache time). This explains why the bug is intermittent and only affects the first launch after an update. Each JS ReconnectApp saves a fresh body before it sends (HttpUtils.ts:107), so the next launch recovers.
    • Any status is cached: nitro-fetch's native cache stores every completed response without checking its status. A 426 is passed to JS like a 200.
    • No version-change handling exists: clearPrefetchOnAppStart runs only on sign-out, account switch, full reconnect, and token updates.
    • History: The prefetch shipped in feat: Enable react-native-nitro-fetch (V4). Removing appversion from the token-refresh body came out of [$250] Update required screen shown on latest iOS staging build after stale NewDot bundle sends outdated appversion, which reported this same symptom. That fix covered only Authenticate. iOS uses the same JS registration path, so it is likely affected too. I haven't verified the iOS native code.
    • Not reproduced: This needs a real Android upgrade across the minimum version. On web, prefetch does nothing, so I didn't run a web test.
    • Open question: The fix assumes the server accepts ReconnectApp without appversion, as it already does for Authenticate. I couldn't check that here.

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/103764) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  3. added
    External
    on Oct 12, 2026
  4. melvin-bot commented on Oct 12, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (External)

  5. changed the title [-][Android] "Update Required" shown after updating the app because the startup ReconnectApp prefetch sends the old `appversion`[/-] [+][$175] [Android] "Update Required" shown after updating the app because the startup ReconnectApp prefetch sends the old `appversion`[/+] on Oct 12, 2026
  6. melvin-bot commented on Oct 12, 2026

    @melvin-bot
  7. taieddie commented on Oct 12, 2026

    @taieddie

    Contributor details
    Your Expensify account email: taieddie8@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~01af851c9a7f771775

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Android, after updating the Expensify app from an older build (below the server's minimum version) to a new build at or above the minimum version, the app displays the "Update Required" screen on the first launch, blocking the user even though the installed version is current.

    What is the root cause of that problem?

    The root cause is that the ReconnectApp startup prefetch serializes and persists the old build's appversion across updates:

    1. In src/libs/HttpUtils.ts, every time a ReconnectApp request is processed, registerPrefetchOnAppStart receives fetchParams with a FormData body populated by enhanceParameters. This body contains appversion: pkg.version of the currently running session.
    2. In src/libs/Prefetch/registerPrefetchOnAppStart/index.ts, registerPrefetchOnAppStart calls prefetchOnAppStart(url, fetchParams) without stripping appversion.
    3. When the user updates the app via the Play Store, the native react-native-nitro-fetch module fires the saved ReconnectApp request at app startup before JavaScript finishes loading. Native only refreshes auth token headers, sending the previously saved body carrying the old appversion.
    4. The server compares the outdated appversion against the minimum version and returns HTTP 426 (Deprecated app version).
    5. When the newly updated JavaScript bundle loads and executes its initial ReconnectApp, it hits the cached or in-flight native prefetch with matching prefetchKey ReconnectApp:<accountID>, receiving the 426 response. HttpUtils sees jsonCode: 426 and calls alertUser(), rendering the UpdateRequiredView.

    While buildAuthenticateBody in registerPrefetchOnAppStart/index.ts already deliberately omits appversion for this exact reason (as documented in lines 27-29), registerPrefetchOnAppStart currently passes the full ReconnectApp fetchParams.body containing appversion into prefetchOnAppStart.

    What changes do you think we should make in order to solve the problem?

    1. In src/libs/Prefetch/registerPrefetchOnAppStart/index.ts:

      • In registerPrefetchOnAppStart, strip appversion from the request body before passing it to prefetchOnAppStart.
      • Create a clean copy of the FormData without mutating the original fetchParams.body (ensuring the live JavaScript request at HttpUtils.ts:118 continues to send appversion for normal version checks):
        • Extract fields from fetchParams.body (using getParts() on React Native or iterating FormData), filter out the appversion field, and build a strippedBody.
        • Pass {...fetchParams, body: strippedBody} to prefetchOnAppStart(url, fetchParamsWithStrippedBody).
      • This aligns ReconnectApp with buildAuthenticateBody, ensuring startup prefetches never lock users out with a stale version string after app upgrades.
    2. In automated unit tests:

      • Add unit test coverage in tests/unit/registerPrefetchOnAppStartTest.ts:
        • Verify that when registerPrefetchOnAppStart is called with a fetchParams.body containing appversion, prefetchOnAppStart is invoked with a body that has appversion removed.
        • Verify that other necessary request parameters (such as clientUpdateID or account identifiers) remain preserved.
        • Verify that the original fetchParams.body passed by HttpUtils is not mutated.

    What alternative solutions did you explore? (Optional)

    I explored appending the active pkg.version to prefetchKey in preparePrefetchRequest so that a new build's JS bundle never matches a prefetch response initiated by an older build. However, stripping appversion directly in registerPrefetchOnAppStart is cleaner and directly matches the existing architectural precedent established by buildAuthenticateBody.

  8. melvin-bot commented on Oct 12, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  9. jloa-dev commented on Oct 12, 2026

    @jloa-dev

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Android, updating the app from the Play Store causes the app to get stuck on the "Update Required" modal on first launch after update, despite the installed build version being current and above the server's minimum requirement.

    What is the root cause of that problem?

    On native platforms, ReconnectApp is prefetched at startup via react-native-nitro-fetch. Each JS ReconnectApp call saves its full request body via registerPrefetchOnAppStart (src/libs/HttpUtils.ts:107). Because the body originates from enhanceParameters, it serializes appversion: pkg.version of the build that executed the previous session.

    When the user updates the app via the Play Store and launches it:

    1. Native startup prefetch sends the saved ReconnectApp body before JS initializes.
    2. The request carries the stale previous build's appversion.
    3. If that previous version has since been deprecated, the backend returns 426 Deprecated app version.
    4. The JS bundle initializes and resolves ReconnectApp directly from the cached prefetch response, triggering alertUser() and showing the blocking "Update Required" modal.

    Notably, buildAuthenticateBody in registerPrefetchOnAppStart/index.ts:27-29 already notes this exact risk and omits appversion on purpose:

    // The `appversion` parameter is omitted intentionally here.
    // This is because it can cause issues during app updates and
    // it is not needed by the "Authenticate" command for token refresh.

    However, this sanitization was never applied to the prefetched ReconnectApp body itself.

    What changes do you think we should make in order to solve the problem?

    In src/libs/Prefetch/registerPrefetchOnAppStart/index.ts:
    Sanitize fetchParams.body before passing to prefetchOnAppStart by stripping appversion, matching the established invariant in buildAuthenticateBody:

    const registerPrefetchOnAppStart: RegisterPrefetchOnAppStart = ({prefetchKey, fetchParams, command, url}) => {
        if (!prefetchKey) {
            return;
        }
    
        registerPrefetchTokenRefresh();
    
        let prefetchParams = fetchParams;
        if (fetchParams.body instanceof FormData) {
            const sanitizedBody = new FormData();
            fetchParams.body.forEach((value, key) => {
                if (key !== 'appversion') {
                    sanitizedBody.append(key, value);
                }
            });
            prefetchParams = {
                ...fetchParams,
                body: sanitizedBody,
            };
        }
    
        prefetchOnAppStart(url, prefetchParams).catch((error) => {
            Log.warn(`[NitroFetch] prefetchOnAppStart failed for ${command}`, {error, fetchParams, url});
        });
    };

    When the app launches after an update, the prefetch request goes through without the stale version parameter, and once JS loads, the active session uses the fresh pkg.version.

    What alternative solutions did you explore? (Optional)

    • Calling removeAllFromAutoprefetch() when a version mismatch is detected: This discards the cache and defeats the performance benefit of startup prefetching on the critical first launch. Omitting appversion lets the prefetch succeed cleanly.

    What specific scenarios should we cover in automated tests?

    In tests/unit/registerPrefetchOnAppStartTest.ts:

    1. Verify that registerPrefetchOnAppStart strips appversion from FormData when dispatching prefetchOnAppStart.
    2. Verify all other parameters (auth tokens, accountID, clientUpdateID) are retained intact.

    Contributor details
    Your Expensify account email: jloa.dev@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0163955a2ba22190aa

  10. 15 remaining items

  11. melvin-bot commented on Oct 22, 2026

    @melvin-bot

    @eVoloshchak 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  12. VickyStash commented on Oct 23, 2026

    @VickyStash
    ContributorAuthor

    Not overdue, the solution was deployed to production

  13. added
    Awaiting Payment
    on Oct 25, 2026
  14. melvin-bot commented on Oct 25, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. melvin-bot commented on Oct 25, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  16. eVoloshchak commented on Oct 26, 2026

    @eVoloshchak
    Contributor

    Contributor+ Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to the comment on the PR: N/A
      Link to the comment on the Issue:

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: https://expensify.slack.com/archives/C01GTK53T8Q/p1793027098524869

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Test:

    1. On iOS or Android native, log in.
    2. Force-close the app and open it again.
    3. Verify that the app opens normally and the Update Required screen isn't shown.
    4. Verify that ReconnectApp is called and successful

    Do we agree 👍 or 👎

  17. eVoloshchak commented on Oct 26, 2026

    @eVoloshchak
    Contributor

    Looks like this issue was linked to a Deploy Blocker #104286

    This wasn't caused by #103842

    #104286 (comment)

    Image Image
  18. mallenexpensify commented on Oct 27, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @eVoloshchak due $175 via NewDot

  19. JmillsExpensify commented on Nov 10, 2026

    @JmillsExpensify
    Contributor

    $175 approved for @eVoloshchak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions