Skip to content

Plugins are currently incompatible with repack for React Native apps #2477

@swrobel

Description

@swrobel

Describe the bug

When using repack & Bugsnag plugins, runtime fails with cannot read property of undefined messages. This seems similar to what has been discussed in #1112, #1481 & #2087 but in a different context.

Steps to reproduce

  1. Build & run app
  2. Note that it errors immediately

Image

Environment

  • Bugsnag version: 8.4.0
  • React Native: 0.78.2
  • Repack: 5.1.2
  • Device: iPhone 16 simulator

Example code snippet

This code is working fine with a standard React Native + Metro setup, but fails when attempting to switch to Repack.

const { createNavigationContainer } = Bugsnag.getPlugin('reactNavigation')
const BugsnagNavigationContainer = createNavigationContainer(RNContainer)

export const NavigationContainer = ({ children }) => {
  const routeNameRef = React.useRef()
  const navigationRef = React.useRef()

  return (
    <BugsnagNavigationContainer
      ref={navigationRef}
      theme={AppTheme}
      linking={linking}
      onReady={() => (routeNameRef.current = navigationRef.current.getCurrentRoute().name)}
      onStateChange={async () => {
        const previousRouteName = routeNameRef.current
        const currentRouteName = navigationRef.current.getCurrentRoute().name

        if (previousRouteName !== currentRouteName) {
          await analytics.logScreenView({
            screen_name: currentRouteName,
            screen_class: currentRouteName,
          })
        }

        // Save the current route name for later comparison
        routeNameRef.current = currentRouteName
      }}
    >
      {children}
    </BugsnagNavigationContainer>
  )
}
Error messages:
[runtime not ready]: TypeError: Cannot read property 'createErrorBoundary' of undefined, js engine: hermes
[runtime not ready]: TypeError: Cannot read property 'createNavigationContainer' of undefined, js engine: hermes

Additional Context

It's worth noting there may be other issues with using repack beyond what's noted here. Even after removing all Bugsnag plugins to get my app to build successfully for dev using repack, I was unable to build for release on either platform.

Android

  CMake Error at node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:103 (target_link_libraries):
    Cannot specify link libraries for target
    "react_codegen_BugsnagReactNativeSpec" which is not built by this project.
  Call Stack (most recent call first):
    CMakeLists.txt:31 (include)


  ninja: error: rebuilding 'build.ninja': subcommand failed

This error does not occur when building without repack.

iOS

/bin/sh -c /Users/swrobel/Library/Developer/Xcode/DerivedData/Bakesy-axkkzifhmobhqbakuiwwffvxrggg/Build/Intermediates.noindex/ArchiveIntermediates/Bakesy/IntermediateBuildFilesPath/Bakesy.build/Release-iphoneos/Bakesy.build/Script-4280C181264C513F000B3DCF.sh
Error: SOURCE_MAP /var/folders/j1/rbgfh8_941j0_nq_tlktst3c0000gn/T//4549eac3146fcde7c7ad5bd22d8c2468-main.jsbundle.map could not be found.
Ensure the --sourcemap-output option is passed to the react-native bundle command.
Command PhaseScriptExecution failed with a nonzero exit code

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting feedbackAwaiting a response from a customer. Will be automatically closed after approximately 2 weeks.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions