newrelic / newrelic-cordova-plugin

A Cordova plugin for the New Relic Mobile SDKs
Apache License 2.0
18 stars 66 forks source link

fix: add empty check for regex groups #65

Closed kennyt276 closed 1 year ago

kennyt276 commented 1 year ago

On iOS, the regex grouping for JS errors can be empty/null. This adds a check for empty/null values so that substringwithRange will not run on -1 value.

ndesai-newrelic commented 1 year ago

@kthai-nr can you write some test cases for this one?

kennyt276 commented 1 year ago

@ndesai-newrelic I added a test for an example error with a stack missing filename, missing method, and missing line number. The github action for the iOS test suite is failing because of emulator issues within GHA but I can confirm this passes locally on my emulator.

From the logs of the iOS GHA run:

[ios-sim] device.name: iPhone 13
[ios-sim] device.runtime: iOS 15.2
[ios-sim] device.id: 31FC42BD-0A90-4781-A948-B5D8165F393F
Error: waitForConnection: Seems like device not connected to local server in 540 secs
Error: waitForConnection: Seems like device not connected to local server in 540 secs

Other cordova plugin projects, both official and unofficial, have been running into this issue as well. It works sometimes, like in the previous commit before adding the tests :shrug: