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

Getting errors from CDVPurchase.Utils.safeCall #1557

Closed
heffthedev opened this issue Apr 10, 2024 · 1 comment
Closed

Getting errors from CDVPurchase.Utils.safeCall #1557

heffthedev opened this issue Apr 10, 2024 · 1 comment

Comments

@heffthedev
Copy link

heffthedev commented Apr 10, 2024

Following error occurs usually when starting the app:
undefined is not an object (evaluating 'callback.name')

Seems to be related to the safeCall funciton found in safe-callback.ts

This code seems to be the culprit:

    export function safeCall<T>(logger: Logger, className: string, callback: Callback<T>, value: T, callbackName: string | undefined, reason: string): void {
      if (!callbackName) {
        callbackName = callback.name || ('#' + md5(callback.toString()));
      }

found in
https://github.com/j3k0/cordova-plugin-purchase/blob/master/src/ts/utils/safe-callback.ts

Not sure if the error is purely related to my code somehow, I couldn't find the cause for it in it yet at least. But I guess a safecall function should not be so picky? ;)

Anyway, if it ends up being my own code's fault, I'd be happy if anyone can point me in the right direction.

Using the latest release of the plugin as of writing: 13.10.1

Cheers.

@j3k0
Copy link
Owner

j3k0 commented May 14, 2024

Hi, the plugin generally use "safeCall" to call callbacks provided by the user (your app), so they are "try-catched" with error properly logged and errors do not mess with the functioning of the plugin. Your code might have somehow registered a undefined callback to one of the events handlers... maybe. Or maybe there's a bug, but it's a single report so that's less likely. I added if (!callback) return; to that function, which seems like a good idea.

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

No branches or pull requests

2 participants