Simple Mistake - Easy FIX next.js sdk can't get the correct error type of credentials provider
Environment
System:
OS: macOS 14.5
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 21.91 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 19.8.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.5.1 - /usr/local/bin/npm
pnpm: 9.3.0 - /usr/local/bin/pnpm
Browsers:
Chrome: 125.0.6422.142
Safari: 17.5
Reproduction URL
https://github.com/TUTUBIG/nextJs-dashboard
Describe the issue
I already found the issue, but need you guys to fix it.
in your code auth/core/src/lib/actions/callback/index.ts you throw CredentialsSignin() which extends Error. However in the logic of catch of this error, you will wrapper any error which doesn't extends AuthError with CallbackRouteError. I think you need to fix it to extends AuthError. I paste some picture of this code below
How to reproduce
Actually I found this issue in the official tutorial project - next.js dashboard Just login with any email & password, it always return the same error. This is because I can't get the accurate error type from your auth SDK.
Expected behavior
Make the error correct & accurate
The types are broken in #11050
Yeah thanks, so the idea was actually to provide another error class to extend for custom credentialErrors that doesnt extend AuthError, because that would end up with our messaging appended to the error.messgae, which users didn't want.
Looks like we just have to also not wrap that one here. I'll take a look shortly
I have check the latest version code "next-auth": "^5.0.0-beta.20", the error is still here , althougth you team have create a new cutomised class SignInError to let CredentialsSignin inherited , and also here are my solutions ,and help your team can check and help resolved, https://github.com/nextauthjs/next-auth/discussions/11684