fix(react-native): remove import cycles that crash under Metro's import transform and fix autolinking builds - #397
Merged
KishanPRao merged 4 commits intoSep 29, 2026
Conversation
…/export transform With breadcrumbs enabled the client crashed with "Cannot read property 'prototype' of undefined" in apps whose Metro config enables experimentalImportSupport without inline requires: FileBreadcrumbsStorage imported BacktraceFileAttachment through the package barrel and the builder imported the client while the client imported the builder, and Metro's static import transform captures those bindings while the barrel is still evaluating. The storage now imports the attachment directly, the builder is defined next to the client, the exception handlers import the client as a type only, and import/no-cycle guards the package.
…ative 0.82+ Expo's autolinking derives the PackageList import from the Gradle namespace, which named a package that does not exist, so the generated PackageList.java failed to compile; the namespace now matches the Java package of ReactNativePackage. The New Architecture check also read newArchEnabled from the root project, which React Native 0.82+ no longer sets, so the library skipped codegen while the app's C++ autolinking still expected its output.
od install rejected apps using dynamic frameworks because PLCrashReporter is a static xcframework, the pod now declares itself a static framework, which is a no-op for static and non-framework setups.
melekr
commented
Sep 28, 2026
| } | ||
| } | ||
| // `BacktraceClientBuilder` lives next to `BacktraceClient` (see the note there); this module keeps the import path. | ||
| export { BacktraceClientBuilder } from '../BacktraceClient'; |
…nking # Conflicts: # packages/react-native/src/builder/BacktraceClientBuilder.ts # packages/react-native/src/handlers/UnhandledExceptionHandler.ts
KishanPRao
approved these changes
Sep 29, 2026
KishanPRao
deleted the
bugfix/react-native-import-cycles-and-autolinking
branch
September 29, 2026 14:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two issues reported on
@backtrace/react-native0.2.2.TypeError: Cannot read property 'prototype' of undefinedunder Metro'sexperimentalImportSupportwithout inline requires. Cause: circular imports (storage → package barrel, client ↔ builder). Metro's static import transform snapshots bindings of modules that are still evaluating.static_frameworkin the podspec.Changes
react-native: remove circular imports that break under Metro's import/export transform
FileBreadcrumbsStorage.ts: importBacktraceFileAttachmentdirectly instead of from the package barrel.BacktraceClient.ts:BacktraceClientBuildermoved into this module. The two classes construct each other, one module removes the cycle.builder/BacktraceClientBuilder.ts: re-export only. Import path and index export unchanged.handlers/ExceptionHandler.ts,handlers/UnhandledExceptionHandler.ts,handlers/android/AndroidUnhandledExceptionHandler.ts:import typeforBacktraceClient, used as a type only..eslintrc.json: new, package-levelimport/no-cycle. Fails on the old sources (9 errors), passes on the new tree, enforced by the rootnpm run lintin CI.tests/clientInitializationTests.spec.ts: new, initializes through the package entry point and the builder, asserts breadcrumb files are exposed as file attachments.react-native: make Android autolinking compile under Expo and React Native 0.82+
android/build.gradle: namespacebacktraceio.library, matching the Java package ofReactNativePackage. Expo autolinking derives thePackageList.javaimport from the namespace.android/build.gradle:isNewArchitectureEnabled()readsnewArchEnabled/react.newArchEnabledfrom the subproject. React Native 0.82+ sets the property on subprojects only.android/gradle.properties: comment. A project-levelnewArchEnabledwould override the app's setting.react-native: support use_frameworks! with dynamic linkage
backtrace-react-native.podspec:s.static_framework = true. PLCrashReporter is a static xcframework,pod installrejected dynamicuse_frameworks!without it. No-op for static and non-framework setups.ref: BT-7787, BT-7788