Skip to content

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

Closed
@lambourn

Description

@lambourn

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions