feat: Enable react-native-nitro-fetch (V4) - #97069
Conversation
|
@mkhutornyi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
react-native-nitro-fetch (V4)react-native-nitro-fetch (V4)
|
|
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9735d65c99
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // This is the entrypoint for prefetching with `react-native-nitro-fetch`. | ||
| try { | ||
| AutoPrefetcher.prefetchOnStart(this) |
There was a problem hiding this comment.
Start the auto-prefetcher on iOS too
This initializes cold-start prefetching only in Android's MainApplication; the inspected ios/AppDelegate.swift proceeds through factory.startReactNative(...) without invoking the corresponding native Nitro auto-prefetch entrypoint. Consequently, registrations created by prefetchOnAppStart() cannot run before the JavaScript bundle loads on iOS, so the startup prefetch feature is ineffective for that entire platform.
Useful? React with 👍 / 👎.
|
@MelvinBot find difference from #95518 |
|
Both of the below deploy blockers have the same root cause and are now fixed in the latest NitroFetch version 1.5.4. The issue was that file URIs with special non-ASCII characters were not resolved correctly on Android, therefore the file was not found.
The reason why this wasn't reproduced locally in V3, was because it was marked as an iOS only issue, therefore i did not test this flow on Android locally: |
|
@mountiny this is ready for an ad-hoc build 🙌🏼 |
|
The App-side code in this PR is essentially identical to the reverted V3 (#95518). No NitroFetch, prefetch, polyfill, or patch logic changed — V4 is V3 re-landed on a newer Both PRs touch the exact same 50 files with the exact same
Every core file — Both PRs also point to the same How this was determinedRepo is shallow so |
|
Please link new Mobile-Expensify PR in description |
@mkhutornyi done! |
react-native-nitro-fetch (V4)react-native-nitro-fetch (V4)
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
@mkhutornyi This should be ready for a retest |
|
Asked for a retest https://expensify.slack.com/archives/C09V78U42D8/p1785164450992079 |
Julesssss
left a comment
There was a problem hiding this comment.
If new blockers arise on this attempt lets resolve rather than revert to save us time.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.mov |
|
No product review needed. |
|
conflicts |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 178ad20f18
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
🤖 Automated code review — scoped to the core app-side logic (I skipped generated nitrogen C++/Kotlin, lockfiles, and the vendored patch). Reviewed at Overall this is a clean re-land: the Most important1. Startup prefetch can be re-armed with the previous session's identity during sign-out (matches the still-unchecked "App sign-out issue" in the description) The prefetch cache is keyed only by the bare command string ( So any Medium2. Native startup
3.
4. Global override of
Nits
MethodReviewed the PR head ( |
|
@mkhutornyi i've addressed the new AI reviewer comments. I've added the I think we can ignore suggestion 3, since this would touch many more files and seems like scope creep. It should be fine to fire-and-forget here.
|
@mkhutornyi i think the reason why we might not have been able to verify, is also because of the files we used to import. Using a file named something like This is fixed now nevertheless 🎉 |
@roryabraham @mountiny @MonilBhavsar
Explanation of Change
This PR is a follow-up for previously reverted PRs:
react-native-nitro-fetch#88110react-native-nitro-fetch(V2) #94469react-native-nitro-fetch(V3) #95518Replace native
fetchwithreact-native-nitro-fetch, then prefetches the startupOpenApp/ReconnectApprequest so it can begin before React Native JS is ready.NitroFetch is a native-backed Fetch API implementation built on Nitro Modules. By globally replacing fetch, Headers, Request, and Response on native, existing fetch(...) callsites and dependencies keep the same API while routing through NitroFetch. Web keeps the browser fetch implementation.
For startup,
prefetchOnAppStart(...)stores theOpenApp/ReconnectApprequest with a stableprefetchKey. On the next cold start, native code replays that request before the React Native runtime is loaded. When JS later sends the same request with the same prefetchKey, NitroFetch can serve the prefetched response from its native cache if it is ready, or fall back to the normal network request if it is not.Fixed and tested the following regressions:
Fixed Issues
$ #90023
PROPOSAL: https://expensify.slack.com/archives/C05LX9D6E07/p1778233186728969
MOBILE-EXPENSIFY: https://github.com/Expensify/Mobile-Expensify/pull/14030
Tests
Offline tests
None needed.
QA Steps
Run a full QA suite on all flows, since the changes in this PR affect all network requests across the whole app.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari