Android: initialize cannot be retried after it throws

未關閉
#515 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 3 天內回覆

@malopezr7 已經在處理了。

開始於 2026年10月30日。

  • #516 來自 @malopezr7 —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
57/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
android, react-native, typescript
領域
backend, mobile

研究方向

Start by reading the Android implementation of ReactNativeBrownfield.initialize, especially the initialized flag, nativeLibsLoaded, and the reactHostFactory path described in the report. Trace the retry behavior when native library loading or host creation throws, and check the Android tests covering initialization if present. Done means a failed call can be retried and the original error is not replaced by an uninitialized shared access.

由索引模型根據 Issue 內容生成。

描述

Description

On Android, ReactNativeBrownfield.initialize marks itself initialized before it does any work (initialized.getAndSet(true)). If loading native libraries or creating the ReactHost throws, the flag stays true:

  1. The first call throws, for example an UnsatisfiedLinkError from a native module's static initializer while PackageList is built inside reactHostFactory.
  2. The host catches it and calls initialize again later.
  3. The second call takes the "already initialized" branch and returns without error, but instance was never set.
  4. The first ReactNativeBrownfield.shared access (for example in ReactNativeFragment) throws UninitializedPropertyAccessException.

nativeLibsLoaded has the same problem: if SoLoader.init or load() throws, a retry skips them.

So a host cannot recover from a failed start, and the real error is replaced by an unrelated one.

Context

We hit the first error in production: a Nitro module's System.loadLibrary failed with dlopen failed: library ".../split_config.arm64_v8a.apk!/lib/arm64-v8a/libX.so" not found on a few Android 13–14 devices. It was transient: the next process loaded it fine. We want to catch it and keep the app usable, but initialize cannot be retried today.

Expected

If initialize throws, the next call runs it again.

Versions
  • @callstack/react-native-brownfield 5.1.0; the same code is in 6.0.1 and main
  • React Native 0.86.3
主要語言
TypeScript
星號
553
分支
58
平均合併
3 天 18 小時
30 天內合併 PR
16

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

callstack/react-native-brownfield 的其他 Issue

查看 callstack/react-native-brownfield 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。