supertokens / supertokens-node

Node SDK for SuperTokens core
https://supertokens.com
Other
281 stars 72 forks source link

TypeError during Password Reset Flow in Next.js using SuperTokens #746

Closed iamalvisng closed 7 months ago

iamalvisng commented 8 months ago

Brief

I encountered a TypeError when attempting to reset a user's password in a Next.js application using SuperTokens. The error occurs when the user clicks "Change Password" after entering the new password and confirming it.

Steps to Reproduce:

  1. Create a new next.js application: npx create-supertokens-app@latest, Next.js -> App Directorty -> Social Login + Email Password
  2. Run it locally
  3. Create an account using email + password
  4. Sign out
  5. Reset password with the associated email
  6. Open reset password link from the email received
  7. Proceed to input new and confirm passwords
  8. Click "Change password"
  9. Observe the UI with an error "Something went wrong. Please try again."
  10. Observe the terminal logged with TypeError Body is unusable...

Error sample:


TypeError: Body is unusable
at specConsumeBody (node:internal/deps/undici/undici:6630:15)
at NextRequest.json (node:internal/deps/undici/undici:6533:18)
at Object.getJSONBody (webpack-internal:///(rsc)/./node_modules/.pnpm/supertokens-node@16.5.1/node_modules/supertokens-node/lib/build/nextjs.js:71:38)
at PreParsedRequest.getJSONBody (webpack-internal:///(rsc)/./node_modules/.pnpm/supertokens-node@16.5.1/node_modules/supertokens-node/lib/build/framework/custom/framework.js:45:33)
at Object.passwordReset [as default] (webpack-internal:///(rsc)/./node_modules/.pnpm/supertokens-node@16.5.1/node_modules/supertokens-node/lib/build/recipe/emailpassword/api/passwordReset.js:36:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Recipe.handleAPIRequest (webpack-internal:///(rsc)/./node_modules/.pnpm/supertokens-node@16.5.1/node_modules/supertokens-node/lib/build/recipe/emailpassword/recipe.js:95:24)
at async Recipe.handleAPIRequest (webpack-internal:///(rsc)/./node_modules/.pnpm/supertokens-node@16.5.1/node_modules/supertokens-node/lib/build/recipe/thirdpartyemailpassword/recipe.js:49:24)
at async SuperTokens.middleware (webpack-internal:///(rsc)/./node_modules/.pnpm/supertokens-node@16.5.1/node_modules/supertokens-node/lib/build/supertokens.js:160:38)
at async eval (webpack-internal:///(rsc)/./node_modules/.pnpm/supertokens-node@16.5.1/node_modules/supertokens-node/lib/build/framework/custom/framework.js:134:28)
at async handleCall (webpack-internal:///(rsc)/./node_modules/.pnpm/supertokens-node@16.5.1/node_modules/supertokens-node/lib/build/nextjs.js:76:40)
at async /Users/path-to-project/node_modules/.pnpm/next@14.0.3_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62609```
rishabhpoddar commented 7 months ago

This issue has been fixed in supertokens-node version >= 16.5.2