Think I might have a bug report regarding user meta/the dashboard. I'm using ThirdPartyEmailPasswo...
o
Think I might have a bug report regarding user meta/the dashboard. I'm using ThirdPartyEmailPassword receipie in my FE and BE configs. And UserMeta/Dashboard in my BE config When I go to the dashboard to edit a users name and click save I get these logs:
Copy code
Error: Initialisation not done. Did you forget to call the SuperTokens.init function?
at Function.getInstanceOrThrowError (/app/node_modules/supertokens-node/lib/build/recipe/emailpassword/recipe.js:199:15)
at /app/node_modules/supertokens-node/lib/build/recipe/dashboard/api/userdetails/userPut.js:76:18
at Generator.next (<anonymous>)
at /app/node_modules/supertokens-node/lib/build/recipe/dashboard/api/userdetails/userPut.js:30:75
at new Promise (<anonymous>)
But when I refresh the dashboard, the meta has actually saved
This is what my nextjs auth handler looks like:
Copy code
supertokens.init(backendConfig());

export default async function superTokens(
  req: NextApiRequest & Request,
  res: NextApiResponse & Response,
) {
  // NOTE: We need CORS only if we are querying the APIs from a different origin
  await NextCors(req, res, {
    methods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'],
    origin: process.env.NEXT_PUBLIC_APP_DOMAIN,
    credentials: true,
    allowedHeaders: ['content-type', ...supertokens.getAllCORSHeaders()],
  });

  await superTokensNextWrapper(
    async (next) => {
      // This is needed for production deployments with Vercel
      res.setHeader(
        'Cache-Control',
        'no-cache, no-store, max-age=0, must-revalidate',
      );
      await middleware()(req, res, next);
    },
    req,
    res,
  );
  if (!res.writableEnded) {
    res.status(404).send('Not found');
  }
}
Ah, also super interesting is that I can edit the user meta in the meta box successfully and it works. The PUT request to /user fails with a 500, but the PUT request to /meta is good, definitely sounds like a bug
r
@nkshah2 can help here
n
We released a fix for this today, could you try clearing browser cookies and trying again?
Or just hard refresh the dashboard to force the browser to fetch it again
o
Oh, sorry, this is self-hosted
n
That shouldn’t be a problem, try clearing cache for the dashboard url and refreshing
o
But my code won't change? I just experienced the issue a moment ago
n
The dashboard is fetched from a cdn which we updated recently, the backend fetches the latest patch version so force reloading should fetch the latest version that is supported by your backend sdk
o
Issue remains
n
Can I see the recipe list you are providing when calling SuperTokens init on the backend?
o
Copy code
const recipeList = [
    ThirdPartyEmailPassword.init({}),
    EmailVerificationNode.init({ mode: 'REQUIRED' }),
    SessionNode.init({ jwt: { enable: true } }),
    UserMetadata.init(),
  ];

  if (process.env.NEXT_SUPERTOKENS_DASHBOARD_KEY) {
    console.log('adding supertokens dashboard recipe');
    recipeList.push(
      Dashboard.init({ apiKey: process.env.NEXT_SUPERTOKENS_DASHBOARD_KEY }),
    );
  } else {
    console.log('skipping supertokens dashboard');
  }
n
Can you send the payload for the api that is failing? From the network tab
o
Copy code
{
  "recipeId": "emailpassword",
  "userId": "e7c863b4-ce35-4b20-924f-d34926f9cd72",
  "phone": "",
  "email": "****@gmail.com",
  "firstName": "Foob",
  "lastName": "Bam"
}
n
Are you seeing any other logs when your server starts up?
o
No, only the one I posted above whenever I try to make the request
Copy code
Error: Initialisation not done. Did you forget to call the SuperTokens.init function?
at Function.getInstanceOrThrowError (/app/node_modules/supertokens-node/lib/build/recipe/emailpassword/recipe.js:199:15)
at /app/node_modules/supertokens-node/lib/build/recipe/dashboard/api/userdetails/userPut.js:76:18
at Generator.next (<anonymous>)
at /app/node_modules/supertokens-node/lib/build/recipe/dashboard/api/userdetails/userPut.js:30:75
at new Promise (<anonymous>)
n
Right can you make an issue for this in SuperTokens node? I’ll take a look at it in a bit
n
Yep that’s right, we’ll be rolling out a fix soon
r
hey @oldhack1364 this bug has been fixed now in our latest version of the node SDK. Version 12.1.1.
o
🙌
58 Views