nativescript-community / sentry

A cross-platform application monitoring tool, with a focus on error reporting.
Apache License 2.0
14 stars 7 forks source link

App crashes on launch "Cannot read property 'log' of undefined" #12

Closed jbm1991 closed 2 years ago

jbm1991 commented 2 years ago

Make sure to check the demo app(s) for sample usage

Done

Make sure to check the existing issues in this repository

Done

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital letter. Done

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it. I am using a framework called the MDK (created by SAP) to create my application. It all works fine, until I try and add this plugin, at which point the app crashes on launch with the error in the callstack below. The issue seems to be similar to the one described here, but unfortunately it was without resolution https://github.com/getsentry/sentry-javascript/issues/4820. I have tried installed tns-core-modules as well, but that made no difference.

Is there any code involved?

I have done no special coding beyond what is described in the README of this repository.

Successfully synced application company.example.app.dev on device emulator-5554.

An uncaught Exception occurred on "main" thread.

Unable to create application sap.mdkclient.MDKAndroidApplication: com.tns.NativeScriptException: Error calling module function 
TypeError: Cannot read property 'log' of undefined

File: (file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:31:0)

StackTrace: 

(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:31:0)
    at consoleSandbox(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/misc.js:101:0)
    at Logger.log(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:30:22)
    at setupIntegration(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:46:4)
    at (file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:58:0)
    at setupIntegrations(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:56:0)
    at BaseClient.setupIntegrations(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/baseclient.js:154:50)
    at Hub.bindClient(file: app/webpack:/myexampleapp/node_modules/@sentry/hub/esm/hub.js:57:0)
    at initAndBind(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/sdk.js:18:0)
    at init(file: app/webpack:/myexampleapp/node_modules/@nativescript-community/sentry/sdk.js:72:16)
    at ./app/Application.ts(file:///data/data/company.example.app.dev/files/app/bundle.js:1010:62)
    at __webpack_require__(file: app/webpack:/myexampleapp/webpack/bootstrap:19:0)
    at ./app/app.ts(file:///data/data/company.example.app.dev/files/app/bundle.js:75:70)
    at __webpack_require__(file: app/webpack:/myexampleapp/webpack/bootstrap:19:0)
    at __webpack_exec__(file:///data/data/company.example.app.dev/files/app/bundle.js:3160:39)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3161:299)
    at __webpack_require__.X(file: app/webpack:/myexampleapp/webpack/runtime/startup entrypoint:6:0)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3161:47)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3166:3)
    at require(:1:266)

TypeError: Cannot read property 'log' of undefined

StackTrace:
java.lang.RuntimeException: Unable to create application sap.mdkclient.MDKAndroidApplication: com.tns.NativeScriptException: Error calling module function 
TypeError: Cannot read property 'log' of undefined
File: (file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:31:0)

StackTrace: 
(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:31:0)
    at consoleSandbox(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/misc.js:101:0)
    at Logger.log(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:30:22)
    at setupIntegration(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:46:4)
    at (file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:58:0)
    at setupIntegrations(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:56:0)
    at BaseClient.setupIntegrations(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/baseclient.js:154:50)
    at Hub.bindClient(file: app/webpack:/myexampleapp/node_modules/@sentry/hub/esm/hub.js:57:0)
    at initAndBind(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/sdk.js:18:0)
    at init(file: app/webpack:/myexampleapp/node_modules/@nativescript-community/sentry/sdk.js:72:16)
    at ./app/Application.ts(file:///data/data/company.example.app.dev/files/app/bundle.js:1010:62)
    at __webpack_require__(file: app/webpack:/myexampleapp/webpack/bootstrap:19:0)
    at ./app/app.ts(file:///data/data/company.example.app.dev/files/app/bundle.js:75:70)
    at __webpack_require__(file: app/webpack:/myexampleapp/webpack/bootstrap:19:0)
    at __webpack_exec__(file:///data/data/company.example.app.dev/files/app/bundle.js:3160:39)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3161:299)
    at __webpack_require__.X(file: app/webpack:/myexampleapp/webpack/runtime/startup entrypoint:6:0)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3161:47)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3166:3)
    at require(:1:266)

TypeError: Cannot read property 'log' of undefined
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6730)
    at android.app.ActivityThread.access$1500(ActivityThread.java:247)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7839)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Caused by: com.tns.NativeScriptException: Error calling module function 
TypeError: Cannot read property 'log' of undefined

File: (file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:31:0)

StackTrace: 

(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:31:0)
    at consoleSandbox(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/misc.js:101:0)
    at Logger.log(file: app/webpack:/myexampleapp/node_modules/@sentry/utils/esm/logger.js:30:22)
    at setupIntegration(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:46:4)
    at (file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:58:0)
    at setupIntegrations(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/integration.js:56:0)
    at BaseClient.setupIntegrations(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/baseclient.js:154:50)
    at Hub.bindClient(file: app/webpack:/myexampleapp/node_modules/@sentry/hub/esm/hub.js:57:0)
    at initAndBind(file: app/webpack:/myexampleapp/node_modules/@sentry/core/esm/sdk.js:18:0)
    at init(file: app/webpack:/myexampleapp/node_modules/@nativescript-community/sentry/sdk.js:72:16)
    at ./app/Application.ts(file:///data/data/company.example.app.dev/files/app/bundle.js:1010:62)
    at __webpack_require__(file: app/webpack:/myexampleapp/webpack/bootstrap:19:0)
    at ./app/app.ts(file:///data/data/company.example.app.dev/files/app/bundle.js:75:70)
    at __webpack_require__(file: app/webpack:/myexampleapp/webpack/bootstrap:19:0)
    at __webpack_exec__(file:///data/data/company.example.app.dev/files/app/bundle.js:3160:39)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3161:299)
    at __webpack_require__.X(file: app/webpack:/myexampleapp/webpack/runtime/startup entrypoint:6:0)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3161:47)
    at (file:///data/data/company.example.app.dev/files/app/bundle.js:3166:3)
    at require(:1:266)

TypeError: Cannot read property 'log' of undefined
    at com.tns.Runtime.runModule(Native Method)
    at com.tns.Runtime.runModule(Runtime.java:689)
    at com.tns.Runtime.run(Runtime.java:681)
    at sap.mdkclient.MDKAndroidApplication.onCreate(MDKAndroidApplication.java:34)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6725)
    ... 9 more

[NSDebugAdapter] Ready to attach to application on 40000
[NSDebugAdapter] Ready to attach to application on 40000
sebj54 commented 2 years ago

Could you send us your main.js file? I had this error in the past and if I remember well, I fixed it by changing the way I initialize Sentry.

jbm1991 commented 2 years ago

Sorry for the delay in replying to this, I have only recently been able to get back to investigating this plugin and it turns out the problem was caused by debug: true in this block, so therefore removing it fixes the problem:

Sentry.init({
  dsn: dsn,
  debug: true, //HERE
  enableAutoPerformanceTracking: true,
  environment: 'dev'
});

Hopefully this helps anyone in the future.

farfromrefug commented 2 years ago

@jbm1991 indeed i am sorry for that the debug flag is not working correctly and i am not sure why