Can I get some help with troubleshooting? I have a...
# support-questions
v
Can I get some help with troubleshooting? I have a user who can't log in, but don't see any reason in the logs.
r
Hey! Yea sure. What is the user doing? And which browser are they using?
v
Chrome. They're trying to sign up for the first time via GitHub but get the "Something went wrong" error.
r
Hmmm. Is that just happening to that user? And no one else?
v
It's happening to two users.
But I can't see any error in the server logs.
r
I see. What is the reply from the api for /signinup API?
v
They say this is in the logs: "variable (__supertokensOriginalFetch) undefined"
r
Hmmm.
Is that the only logs?
v
Yeah.
What's your GitHub? Could I add you so you can try logging in?
r
Strange.
Yea sure. My GitHub is rishabhpoddar
Please add me
I’ll try logging in now
v
I need to add you to our allow-list, will let you know once that's done
r
cool.
v
I assume SuperTokens doesn't have any issues with Firefox? I've only tested on Chrome.
r
no issues with firefox
v
r
thanks
seeing now
right.. so i can see the issue as well.
The signinup API is returning a 500 error
So probably some issue on your server customisation code?
Do you see any logs there for it?
v
Nope, I don't see any errors showing up there.
r
hmm. Can I see the customisation that you have made for the signinup API? How are you handling erros in your app? Cause the API is returning 500 error code, which means that the API throws some error.
v
I'm using the supertoken error handler:
Copy code
app.setErrorHandler(errorHandler());
r
ah right. Can you add a generic erorr handler to your app?
like:
Copy code
app.use((err, req, res, next) => {
  console.log(err)
  next(err);
})
and add that AFTER the supertokens error handler.
v
r
What is the output?
customisation seems about right.. one of the functions being called is probably throwing an error.
or you could wrap the whole thing in a try / catch and see what the error is like this:
Copy code
apis: (originalImplementation) => {
              return {
                ...originalImplementation,
                signInUpPOST: async function (input) {
                  if (originalImplementation.signInUpPOST === undefined) {
                    throw Error("Should never come here");
                  }
                  try {
                    let response = await originalImplementation.signInUpPOST(
                      input
                    );

                    if (response.status === "OK") {
                      const user = new UserAccount(response.user.id);
                      const token = response.authCodeResponse.access_token;
                      await user.saveAccessToken(Providers.GitHub, token);
                    }

                    return response;
                  } catch (err) {
                    console.log(err)
                    throw err;
                  }
                },
              };
            },
          },
        }),
v
Thanks, deploying now.
r
cool
v
I think I found the issue. Is it correct that a session is created before the signInAndUp function is called?
r
You mean before
originalImplementation.signInUpPOST
is called? Or the override.functions.signInUp function?
v
The override function one.
r
right. So the function there is called
signInUp
and not
signInAndUp
But, the session is created after that function returns
v
Huh, weird. It seems like the session creation is happening first.
And that's failing because our session handler attempts to get the token.
r
So signInUpPOST calls: - signInUp - If signInUp returns success, then createNewSession is called from the session recipe.
Which session are you referring to? The github access_token? Or the supertokens session?
v
Supertokens
r
right. So SuperTokens session is created after signInUp function is called
v
But before signInUpPost?
This part was failing
r
yes, before signInUpPost returns
right. And it's failing with what error?
v
It can't find the token in the DB
r
ah i see.
v
Since we save the token in signInUpPost
r
so the token from the db is added after signInUpPost returns. But createNewSession is called before signInUpPost returns
v
Exactly
Should I be saving the token in a different hook?
r
No. You will have to save post signInUpPost returns, but instead of adding the role in createNewSession, you can add the role after you have saved the access token in the db. You can do that by using response.session.updateAccessTokenPayload function
v
Can you try logging in now? I think that fixed it.
r
let me try.
works!
Aweosme
v
Thanks so much for your help!