fix(harmony): safeguard binary version sync against background-thread resource loading failures - #592
Conversation
…ors and cache buildTime
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesUpdateContext Caching and Sync Guard
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
harmony/pushy/src/main/ets/UpdateContext.tsOops! Something went wrong! :( ESLint: 8.57.1 Error: .eslintrc.js » Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
* 'master' of github.com:reactnativecn/react-native-update: fix(harmony): safeguard binary version sync against thread-safety errors and cache buildTime (reactnativecn#592) update expo 54
This PR implements a safety guard and caching layer for binary version synchronization to prevent update state wipes during soft reloads:
Background & Issue
During a soft reload, the React Native container initializes its TurboModules (including
Pushy) on a background JS thread. TheUpdateContextconstructor callssyncStateWithBinaryVersion()which tries to readmeta.jsonsynchronously viaresourceManager.getRawFileContentSync('meta.json').In HarmonyOS, synchronous resource manager APIs are not thread-safe and throw exceptions if called from non-UI threads. The exception is silently caught, returning an empty string
"". Because this empty string doesn't match the previously stored build time, the system assumes the binary has been updated and clears the entire update Preferences.Solution
syncStateWithBinaryVersion():packageVersionandbuildTimeinside static class fields during the first resolution (which always runs on the Main/UI thread in the bundle provider).Unit tests pass successfully.
Summary by CodeRabbit