Skip to content

App crashes with Reflect.construct.apply error during Purchases SDK log handler setup (Expo 54, RN 0.81.4, React 19) #1436

@yahavf6

Description

@yahavf6

Checklist:

Describe the bug

The app crashes immediately on launch with a Reflect.construct error originating from the Purchases SDK's
error logging mechanism. The crash occurs when the SDK attempts to set up its log handler, specifically
when creating a custom error class for stack trace capture.

  1. Environment
    a. Platform: iOS (development simulator)
    b. SDK version: react-native-purchases@9.5.1
    c. OS version: macOS Darwin 24.6.0 (iOS Simulator)
    d. Xcode/Android Studio version: Xcode (version TBD based on macOS 24.6.0)
    e. React Native version: 0.81.4
    f. SDK installation: Package manager (pnpm 10.12.3)
    g. How widespread is the issue: 100% of launches in development environment
    h. IOS: 26.0.1
  2. Debug logs that reproduce the issue
  Code: construct.js
    2 | var setPrototypeOf = require("./setPrototypeOf.js");
    3 | function _construct(t, e, r) {
  > 4 |   if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
      |                                                                 ^
    5 |   var o = [null];
    6 |   o.push.apply(o, e);
    7 |   var p = new (t.bind.apply(t, o))();

  Call Stack:
    construct (apps/mobile/<native>)
    apply (apps/mobile/<native>)
    _construct
  (node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/construct.js:4:65)
    Wrapper
  (node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/wrapNativeSuper.js:15:23)
    construct (apps/mobile/<native>)
    _callSuper
  (node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/callSuper.js:5:108)
    NamelessError (node_modules/.pnpm/@expo+metro-runtime@6.1.2_expo@54.0.12_react-dom@19.1.0_react-native@
  0.81.4_react@19.1.0/node_modules/@expo/metro-runtime/src/metroServerLogs.native.ts:102:20)
    captureCurrentStack (node_modules/.pnpm/@expo+metro-runtime@6.1.2_expo@54.0.12_react-dom@19.1.0_react-n
  ative@0.81.4_react@19.1.0/node_modules/@expo/metro-runtime/src/metroServerLogs.native.ts:106:27)
    HMRClient.log (node_modules/.pnpm/@expo+metro-runtime@6.1.2_expo@54.0.12_react-dom@19.1.0_react-native@
  0.81.4_react@19.1.0/node_modules/@expo/metro-runtime/src/metroServerLogs.native.ts:39:79)
    console.level (node_modules/.pnpm/react-native@0.81.4_@babel+core@7.28.4_@types+react@19.1.17_react@19.
  1.0/node_modules/react-native/Libraries/Core/setUpDeveloperTools.js:41:24)
    setLogHandler$argument_0 (node_modules/.pnpm/react-native-purchases@9.5.1_react-native-web@0.21.1_react
  -native@0.81.4_react@19.1.0/node_modules/react-native-purchases/dist/purchases.js:114:38)
    eventEmitter.addListener$argument_1 (node_modules/.pnpm/react-native-purchases@9.5.1_react-native-web@0
  .21.1_react-native@0.81.4_react@19.1.0/node_modules/react-native-purchases/dist/purchases.js:72:21)
  1. Steps to reproduce
    - Install react-native-purchases@9.5.1 in an Expo 54.0.11 project with React Native 0.81.4
    - Import and initialize the Purchases SDK
    - Launch the app in development mode with Expo Metro bundler
    - Expected behavior: App launches successfully with Purchases SDK initialized
    - Actual behavior: App crashes immediately with Reflect.construct error during SDK initialization
  2. Other information
    - The error originates from purchases.js:114:38 when setting up the log handler
    - This appears to be related to Babel runtime helpers (@babel/runtime@7.28.4) and how the SDK creates
    custom error classes for logging
    - The crash happens before any SDK methods are called, suggesting it's an initialization/setup issue
    - Environment: Expo 54.0.11, React 19.1.0, React Native 0.81.4
    - Package manager: pnpm 10.12.3
    - Node.js: v22.19.0
    - The issue may be related to the interaction between:
    • Expo Metro runtime's error capturing mechanism
    • react-native-purchases' custom error logging
    • Babel's native super class wrapping helpers
      - This appears to be a compatibility issue with the newer Expo/React Native/React versions

Additional context
This is a monorepo project using Turborepo. The mobile app is an Expo-managed workflow project. The error
prevents the SDK from initializing entirely, making the app unusable in development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions