I have Firebase Crashlytics set up on a project and I know it's working (since it occasionally indeed shows some of the errors at the correct file).
I try crashlytics().recordError(err, 'api_error')
(where err
is a valid Error subclass object from axios) yet it is not seen on Crashlytics dashboard in Firebase console.
- I am testing on a TestFlight build, not from Xcode/debugger/packager
- I've waited and restarted the app several times (since I think they get uploaded afterwards)
- I don't have any filters in issues list in Crashlytics dashboard.
- I see a few of other warnings/non-fatal JS-side errors in issues, indicating Firebase SDK initialized correctly (otherwise I should not see anything).
Yet, it doesn't reflect to the dashboard. I've tried it several times. What am I doing wrong? (I'm on iOS 16.6)
UPDATE: I can perfectly force a crash with crashlytics().crash()
and it shows in the dashboard immediately. There seems to be something to do with recordError
. I've also changed crashlytics_debug_enabled
to true
in firebase.json
yet no avail.
UPDATE 2:
When I dug further I've seen that recordError internally calls:
StackTrace.fromError(error, { offline: true }).then(stackFrames => {
this.native.recordError(createNativeErrorObj(error, stackFrames, false, jsErrorName));
});
And that fromError is defined as (in stacktrace library):
fromError: function StackTrace$$fromError(error, opts) {
opts = _merge(_options, opts);
var gps = new StackTraceGPS(opts);
return new Promise(function(resolve) {
var stackframes = _filtered(ErrorStackParser.parse(error), opts.filter);
resolve(Promise.all(stackframes.map(function(sf) {
return new Promise(function(resolve) {
function resolveOriginal() {
resolve(sf);
}
gps.pinpoint(sf).then(resolve, resolveOriginal)['catch'](resolveOriginal);
});
})));
}.bind(this));
},
After stepping through breakpoints I've detected that the error stems from _filtered(ErrorStackParser.parse(error), opts.filter); line. ErrorStackParser. The parse method in there is (in error-stack-parser library):
parse: function ErrorStackParser$$parse(error) {
if (typeof error.stacktrace !== 'undefined' || typeof error['opera#sourceloc'] !== 'undefined') {
return this.parseOpera(error);
} else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
return this.parseV8OrIE(error);
} else if (error.stack) {
return this.parseFFOrSafari(error);
} else {
throw new Error('Cannot parse given Error object');
}
},
My axios error comes correctly until the method above, but the code throws at throw new Error('Cannot parse given Error object');, throwing all the way upstream, therefore the error can never be submitted.
(also submitted as issue to the repo https://github.com/invertase/react-native-firebase/issues/7282)