Android: initialize cannot be retried after it throws

Aperta
#515 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@malopezr7 ci sta già lavorando.

Dal 30/10/2026.

  • #516 di @malopezr7 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android, react-native, typescript
Ambito
backend, mobile

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
TypeScript
Stelle
553
Fork
58
Merge medio
3g 18h
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di callstack/react-native-brownfield

Tutte le issue di callstack/react-native-brownfield

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.