Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-675

send_reset_password_email get callback from the nonexistent 2nd arguments

      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``

      Unable to find source-code formatter for language: sendresetpasswordemail. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
              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

            Assignee:
            kenneth.geisshirt@mongodb.com Kenneth Geisshirt (Inactive)
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: