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

send_reset_password_email get callback from the nonexistent 2nd arguments #3037

Closed
deckyfx opened this issue Jul 7, 2020 · 1 comment
Closed
Assignees

Comments

@deckyfx
Copy link

deckyfx commented Jul 7, 2020

Realm version: 10.0.0-beta.7

When calling sendResetPasswordEmail, it throw an error

[Tue Jul 07 2020 17:17:11.211]  WARN     Possible Unhandled Promise Rejection (id: 1):
Error: callback must be of type 'function', got (undefined)
_sendResetPasswordEmail@[native code]
http://localhost:8081/node_modules/realm/lib/email_password_provider_client_methods.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:48:39
tryCallTwo@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3353:9
doResolve@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3517:25
Promise@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3376:14
sendResetPasswordEmail@http://localhost:8081/node_modules/realm/lib/email_password_provider_client_methods.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:47:25
...

i think the culprit is here:
email_password_provider_client_methods.js

        return new Promise((resolve, reject) => {
            this._sendResetPasswordEmail(email, (err) => {
                if (err) {
                    reject(err);
                } else {
                    resolve();
                }
            });
        });
    },

if my guess is right, it will call this:

js_email_password_provider.hpp

template<typename T>
void EmailPasswordProviderClientClass<T>::send_reset_password_email(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) {
    args.validate_count(2);

    auto& client = *get_internal<T, EmailPasswordProviderClientClass<T>>(ctx, this_object);

    auto email = Value::validated_to_string(ctx, args[0], "email");
    auto callback = Value::validated_to_function(ctx, args[2], "callback");

    client.send_reset_password_email(email, make_callback_handler<T>(ctx, this_object, callback));
}

it checks if it called with 2 arguments, but then it takes the callback from 2nd arguments array which is undefined, it should be 1st array element

@kneth
Copy link
Contributor

kneth commented Jul 8, 2020

@deckyfx Thank you for reporting. We have a fix in #3043.

@kneth kneth added the T-Bug label Jul 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants