Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashlytics: NullpointerException in recordError() if the StackFrame's functionName is falsy due to arrow-function #65

Closed
lambourn opened this issue Mar 16, 2022 · 0 comments · Fixed by #66

Comments

@lambourn
Copy link
Contributor

I do not have real steps to reproduce but on Android, calling firebase().crashlytics().recordError(new Error("foobar")); raises a
java.lang.NullPointerException if the functionName of the StackFrame is not available. This is a {N} Angular application bzw.

In my case, the relevant parts of the original JS runtime stack trace looks like this, see inline comments for context:

// handleError() is our custom Angular ErrorHandler, therefore it is in bundle.js
handleError(file:///data/data/foo.bar.dev/files/app/bundle.js:1215:27)
at next(file:///data/data/foo.bar.dev/files/app/vendor.js:43721:42)
at SafeSubscriber.__tryOrUnsub(file:///data/data/foo.bar.dev/files/app/vendor.js:158609:16)
at SafeSubscriber.next(file:///data/data/foo.bar.dev/files/app/vendor.js:158547:22)
at Subscriber._next(file:///data/data/foo.bar.dev/files/app/vendor.js:158493:26)
at Subscriber.next(file:///data/data/foo.bar.dev/files/app/vendor.js:158470:18)
at Subject.next(file:///data/data/foo.bar.dev/files/app/vendor.js:158240:25)
at emit(file:///data/data/foo.bar.dev/files/app/vendor.js:40373:15)
// this part of the stack is actually the body of an arrow function
//   zone.runOutsideAngular(() => zone.onError.emit(error));
// I guess this is why there is no functionName as it is anonymous
at (file:///data/data/foo.bar.dev/files/app/vendor.js:76877:55)
at invoke(file:///data/data/foo.bar.dev/files/app/vendor.js:179011:26)
at run(file:///data/data/foo.bar.dev/files/app/vendor.js:178773:43)
at runOutsideAngular(file:///data/data/foo.bar.dev/files/app/vendor.js:76751:28)
at onHandleError(file:///data/data/foo.bar.dev/files/app/vendor.js:76877:18)
at handleError(file:///data/data/foo.bar.dev/files/app/vendor.js:179015:37)

This empty function name causes an java.lang.NullPointerException error here as the methodName argument of a java.lang.StackTraceElement may not be null:

traceElements[i] = new java.lang.StackTraceElement('', item.functionName, item.fileName, -1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant