app.emailPasswordAuth.registerUser() throws an error

Hi,

I’m experiencing an issue in production. My users cannot sign up using the Email/Password provider. When trying to do so, an error is returned by realm-web :

Error: Request failed (POST https://stitch.mongodb.com/api/client/v2.0/app/my-app-id/auth/providers/local-userpass/register): TypeError: 'captureStackTrace' is not a function (status 400)
    at Function.fromRequestAndResponse (bundle.dom.es.js:2677)
    at async Fetcher.fetch (bundle.dom.es.js:2841)
    at async Fetcher.fetchJSON (bundle.dom.es.js:2858)
    at async EmailPasswordAuth.registerUser (bundle.dom.es.js:1073)

I had never seen that error before and I don’t think there’s been any recent modifications on that part of our webapp. Could it be a bug on MongoDB Realm’s side? Has anyone encountered the same error before?

Thanks,

Benjamin

Hi Benjamin,

just checking that the actual error had your real app-id in the URL rather than my-app-id?

Was there anything in the Realm logs?

Was it a transient error, or is it still being seen?

Hi Andrew,

I do use the right app id but I didn’t want to share it on a forum :wink:

The issue is still being seen. I don’t have much more info except the error log in the MongoDB Realm dashboard:

Error:

TypeError: 'captureStackTrace' is not a function
Stack Trace:

TypeError: 'captureStackTrace' is not a function at FetchError (node_modules/node-fetch/lib/index.js:192:25(32)) at events:10:4454(129) at K (_http_client:10:6817(98)) at events:10:4454(129) at M (stream:10:9105(24)) at T (stream:10:8932(184)) at stream:10:9716(51) at onStreamRead (internal/stream_base_commons:10:2040(41))

Do you have any idea what could cause this error ?

Thanks,

Benjamin

Which mode are you using to confirm users?

If it’s a function, what does that function look like?

I run a confirmation function. Yeah I thought it might come from that but I do not see where the issue could come from in this function:

  exports = async ({ token, tokenId, username, password }) => {
    const fetch = require('node-fetch');

    const addUserToMailerliteGroupAPIEndPoint = 'https://api-endpoint.com';
    const groupId = 'mailerlitegroupid';

    try {
      await fetch(`${addUserToMailerliteGroupAPIEndPoint}/add-user-to-group`, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          groupId,
          email: username,
          name: '',
        }),
      });
    } catch (error) {
      console.log(error);
      // Do nothing
    }
    
    return { status: 'pending' };
  };

We currently have implemented a flow where the user gets sent an automatic email from mailerlite when he/she signs up.

Okay it came from that function, wrong endpoint !! The error is still very misleading :thinking:

Anyway, thanks for your message, you unlocked me !

Best,

Benjamin

Glad to hear that you found the fix!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.