Sentry-react-native: SentryError: Native Client is not available, can't start on native.

Created on 6 Jun 2020  ·  8Comments  ·  Source: getsentry/sentry-react-native

OS:

  • [ ] Windows
  • [x] MacOS
  • [ ] Linux

Platform:

  • [x] iOS
  • [ ] Android

SDK:

  • [x] @sentry/react-native (>= 1.0.0)
  • [ ] react-native-sentry (<= 0.43.2)

SDK version: 1.4.3

react-native version: 0.62.2

jest version: 26.0.1

Are you using Expo?

  • [ ] Yes
  • [x] No

Are you using sentry.io or on-premise?

  • [x] sentry.io (SaaS)
  • [ ] on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

no issue

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: "https://xxx:[email protected]/zzz",
})

I have following issue:

Jest tests started failing a bunch of tests in different locations after upgrading from 1.4.2 to 1.4.3. The error is the following:

SentryError: Native Client is not available, can't start on native.

Steps to reproduce:

Actual result:

  ● Test suite failed to run

    SentryError: Native Client is not available, can't start on native.

      at new SentryError (node_modules/@sentry/utils/src/error.ts:9:5)
      at Object.<anonymous> (node_modules/@sentry/react-native/src/js/wrapper.ts:287:21)
      at Object.<anonymous> (node_modules/@sentry/react-native/src/js/transports/native.ts:4:16)

Expected result:

Test passes.

Type Bug

Most helpful comment

@askielboe Hmm, looking at the original code example you gave, make sure you set enableNative: false in the Sentry.init options if you are going to run @sentry/react-native without a native device:

Sentry.init({
    dsn: '...',
    enableNative: false
})

All 8 comments

Hi, PR #919 will fix this when it is merged. Sorry about that.

The fix was shipped in version 1.4.5. 😄

Same issue with 1.4.5:

"@sentry/[email protected]":
  version "1.4.5"
  resolved "https://registry.yarnpkg.com/@sentry/react-native/-/react-native-1.4.5.tgz#bbbd431604e8436309c3b385904856708768cb52"
  integrity sha512-Ruh3992WsaNSDwwV8b3KFyus6INK45ZwG1TvpvJLh/Dsq7YfWcSymdJXPqEI+xSgDSft1qlIbwptyVvLCHMWlA==
  dependencies:
    "@sentry/browser" "^5.16.1"
    "@sentry/core" "^5.16.1"
    "@sentry/hub" "^5.16.1"
    "@sentry/integrations" "^5.16.1"
    "@sentry/types" "^5.16.1"
    "@sentry/utils" "^5.16.1"
    "@sentry/wizard" "^1.1.4"

@askielboe Hmm, looking at the original code example you gave, make sure you set enableNative: false in the Sentry.init options if you are going to run @sentry/react-native without a native device:

Sentry.init({
    dsn: '...',
    enableNative: false
})

Okay, thanks. I guess the correct thing is to mock Sentry when running under jest, but I couldn't make it work.. So I used this workaround instead:

Sentry.init({
  dsn:
    "...",
  enableNative: process.env.JEST ? false : true, // disable native module when running tests
})

Then in package.json:

  "scripts": {
    "test": "JEST=true ./node_modules/.bin/jest",
  },

thanks @jennmueng the enableNative:false fixed my issue :-)

@sentry

Not working for me:

yarn run v1.22.4
$ jest App.test.tsx
 FAIL  __tests__/App.test.tsx
  ● Test suite failed to run

    TypeError: Cannot convert undefined or null to object
        at assign (<anonymous>)

      at _extends (node_modules/@babel/runtime/helpers/extends.js:16:19)
      at node_modules/@testing-library/react-native/dist/preset/mock-modules.js:41:25
      at Object.<anonymous> (node_modules/react-native/Libraries/Animated/src/AnimatedEvent.js:15:21)

  console.warn
    Sentry Logger [Warn]: Note: Native Sentry SDK is disabled.

      at CustomConsole.console.warn (node_modules/react-native/Libraries/LogBox/LogBox.js:36:13)
      at node_modules/@sentry/utils/src/logger.ts:46:22
      at Object.consoleSandbox (node_modules/@sentry/utils/src/misc.ts:174:18)
      at Logger.warn (node_modules/@sentry/utils/src/logger.ts:45:5)
      at Object._callee2$ (node_modules/@sentry/react-native/src/js/wrapper.ts:93:16)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:274:22)

  console.log
    Sentry Logger [Log]: Integration installed: ReactNativeErrorHandlers

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

  console.log
    Sentry Logger [Log]: Integration installed: Release

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

  console.log
    Sentry Logger [Log]: Integration installed: InboundFilters

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

  console.log
    Sentry Logger [Log]: Integration installed: FunctionToString

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

  console.log
    Sentry Logger [Log]: Integration installed: Breadcrumbs

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

  console.log
    Sentry Logger [Log]: Integration installed: LinkedErrors

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

  console.log
    Sentry Logger [Log]: Integration installed: UserAgent

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

  console.log
    Sentry Logger [Log]: Integration installed: DebugSymbolicator

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

  console.log
    Sentry Logger [Log]: Integration installed: RewriteFrames

      at node_modules/@sentry/utils/src/logger.ts:36:22
          at Array.forEach (<anonymous>)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        4.03s
Ran all test suites matching /App.test.tsx/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sercanov picture sercanov  ·  3Comments

jussirantala picture jussirantala  ·  3Comments

ThomasLarge picture ThomasLarge  ·  3Comments

JonasBAJ picture JonasBAJ  ·  3Comments

juhaelee picture juhaelee  ·  3Comments