newrelic / newrelic-capacitor-plugin

Mobile instrumentation plugin for the Capacitor hybrid mobile platform by Ionic
Apache License 2.0
7 stars 10 forks source link

vendor.js: Unhandled Promise rejection: []: Cannot read properties of undefined (reading 'newrelic') #72

Closed hughknaus closed 4 months ago

hughknaus commented 5 months ago

Description

I'm getting the below error in the console.log when starting the application:

index.js:40 []: Unhandled Promise rejection: []: Cannot read properties of undefined (reading 'newrelic') []: ; Zone: []: <root> []: ; Task: []: Promise.then []: ; Value: []: TypeError: Cannot read properties of undefined (reading 'newrelic') []: TypeError: Cannot read properties of undefined (reading 'newrelic')
    at http://localhost:8100/vendor.js:13197:46
    at _ZoneDelegate.invoke (http://localhost:8100/polyfills.js:8293:158)
    at Zone.run (http://localhost:8100/polyfills.js:8078:35)
    at http://localhost:8100/polyfills.js:9154:28
    at _ZoneDelegate.invokeTask (http://localhost:8100/polyfills.js:8320:171)
    at Zone.runTask (http://localhost:8100/polyfills.js:8124:37)
    at drainMicroTaskQueue (http://localhost:8100/polyfills.js:8491:23)

Also, seeing empty array brackets [] before each console logging output like:

[]: DEBUG::HomePageService::locateHomePage
[]: AppMenu ctor called
[]: AppMenuFooter Ctor called!

Steps to Reproduce

Expected Behavior

Expect the app to run without newrelic errors. Removed the newrelic pieces, app runs fine.

Your Environment

Apple M2 Max, Sonoma 14.3 Ionic/Angular app building with Capacitor/Trapeze Serving to local browser (Chrome)

ndesai-newrelic commented 5 months ago

@hughknaus can you run this on mobile phone? can you share sample app for this issue?

hughknaus commented 5 months ago

I tried in Android emulator first but the app now crashes with this log:

2024-02-12 09:24:31.335 18520-18587 Capacitor               <MYAPP>                 E  Serious error executing plugin
                                                                                                    java.lang.reflect.InvocationTargetException
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138)
                                                                                                        at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:797)
                                                                                                        at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)
                                                                                                        at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                        at android.os.Looper.loop(Looper.java:294)
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67)
                                                                                                    Caused by: java.lang.IllegalArgumentException: noticeHttpTransaction: URL is malformed: /svg/close.svg
                                                                                                        at com.newrelic.agent.android.NewRelic.noticeHttpTransaction(NewRelic.java:579)
                                                                                                        at com.newrelic.capacitor.plugin.NewRelicCapacitorPluginPlugin.noticeHttpTransaction(NewRelicCapacitorPluginPlugin.java:429)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138) 
                                                                                                        at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:797) 
                                                                                                        at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) 
                                                                                                        at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) 
                                                                                                        at android.os.Handler.handleCallback(Handler.java:958) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:205) 
                                                                                                        at android.os.Looper.loop(Looper.java:294) 
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67) 
2024-02-12 09:24:31.337 18520-18587 AndroidRuntime          <MYAPP>                E  FATAL EXCEPTION: CapacitorPlugins
                                                                                                    Process: <MYAPP>, PID: 18520
                                                                                                    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
                                                                                                        at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:806)
                                                                                                        at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)
                                                                                                        at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                        at android.os.Looper.loop(Looper.java:294)
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67)
                                                                                                    Caused by: java.lang.reflect.InvocationTargetException
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138)
                                                                                                        at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:797)
                                                                                                        at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) 
                                                                                                        at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) 
                                                                                                        at android.os.Handler.handleCallback(Handler.java:958) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:205) 
                                                                                                        at android.os.Looper.loop(Looper.java:294) 
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67) 
                                                                                                    Caused by: java.lang.IllegalArgumentException: noticeHttpTransaction: URL is malformed: /svg/close.svg
                                                                                                        at com.newrelic.agent.android.NewRelic.noticeHttpTransaction(NewRelic.java:579)
                                                                                                        at com.newrelic.capacitor.plugin.NewRelicCapacitorPluginPlugin.noticeHttpTransaction(NewRelicCapacitorPluginPlugin.java:429)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138) 
                                                                                                        at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:797) 
                                                                                                        at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) 
                                                                                                        at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) 
                                                                                                        at android.os.Handler.handleCallback(Handler.java:958) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:205) 
                                                                                                        at android.os.Looper.loop(Looper.java:294) 
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67) 

I searched the app for close.svg and the only reference was inside this file: /Volumes/Storage/_projects/<MYAPP>/android/app/build/intermediates/incremental/mergeDebugAssets/merger.xml. I'm betting that is Ionic's close image.

I couldn't find any information relating to the merger.xml file. I'm assuming that it is an artifact of the Capacitor build??

I'll try to come up with an example app. This is in a fairly large commercial product that used to use the Cordova implementation of including a large block of JS in the index.html file but has undergone conversion to Capacitor.

ndesai-newrelic commented 5 months ago

@hughknaus i can fix this issue from our side, did you try to run that on ios device?

hughknaus commented 5 months ago

@ndesai-newrelic no, i have not tried on the iOS side yet. Troubleshooting has always been easy in browser, then Android, and finally iOS. But I'll give it try on the iOS side now, I'll let you know in a little bit what I see.

ndesai-newrelic commented 5 months ago

@hughknaus i got your issue on android side, i just want to make sure it is happening on ios side or not. if you are enterprise customer, you can reach out to our support team through GTSE.

hughknaus commented 5 months ago

@ndesai-newrelic the iOS side definitely doesn't run as expected, but a little harder to tell where the issue lies, here's an XCode screenshot with some Newrelic warnings (on simulator, not actual device):

![Uploading Screenshot 2024-02-12 at 2.22.41 PM.png…]()

ndesai-newrelic commented 5 months ago

@hughknaus i pushed some changes on our main branch, can you test your app in this release?

hughknaus commented 5 months ago

@ndesai-newrelic thanks! I'll give it a try tomorrow, Thursday. I'm in Mountain TZ.

ndesai-newrelic commented 4 months ago

@hughknaus i am able to fix the issue which you are getting it on browser.

Toxiapo commented 4 months ago

Hi @ndesai-newrelic, I am having a similar issue on browser, but works fine on ios, and I am wondering if there's a release I can try with the fix? Thanks

ndesai-newrelic commented 4 months ago

@Toxiapo can you check this release on browser also?

Toxiapo commented 4 months ago

@ndesai-newrelic Updated to 1.3.5 and things seem to be working great now! Thank you

hughknaus commented 4 months ago

@ndesai-newrelic so 1.3.5 does partially fix the issue. I can at least load the app in browser now. I do continue to see the leading empty arrays in the console.log, however, it's no longer on every line but still a majority. For example:

[]: jobFilterService:: []: 2 index.js:22
[]: [object Object] 2 index.js:22
[]: [object Object] index.js:22 
[]: jobFilterService:: []: usw:hknaus@email.com index.js:22 
[]: jobFilterService:: []: usw:hknaus@email.com index.js:22
[]: joblist::ionViewDidEnter fromJobStart = false index.js:22 

This is what it normally looks like:

jobFilterService:: 7538.28a007c40e5a86a4.js:1 
jobFilterService:: usw:hknaus@email.com 7538.28a007c40e5a86a4.js:1 
jobFilterService:: usw:hknaus@email.com
joblist::ionViewDidEnter fromJobStart = false 6377.dd8d15ed994e8c44.js:1

I'm continuing to test Android and iOS today.

ndesai-newrelic commented 4 months ago

@hughknaus That's an astute observation. We are currently automatically collecting logs which may be adding these empty arrays. Could you please open a new issue for this?