-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RangeError: Maximum call stack size exceeded on NextJS v15 Middleware #14245
Comments
Hi @CarlWangMK thanks for reporting this issue. Looking at the screenshot shown error log and stack trace, it look like an internal function for parsing the Amplify configuration cannot terminate the recursive process. Could you provide the |
Hey @HuiSF, the For my project, it looks like this: export const authConfig: ResourcesConfig["Auth"] = {
Cognito: {
userPoolClientId: String(process.env.NEXT_PUBLIC_USER_CLIENT_ID),
userPoolId: String(process.env.NEXT_PUBLIC_USER_POOL_ID),
loginWith: {
email: true,
},
userAttributes: {
email: {
required: true
},
given_name: {
required: true
},
family_name: {
required: true
},
},
}
} whereas in the sample repository I provided, it just has the userPoolIds: export const authConfig: ResourcesConfig["Auth"] = {
Cognito: {
userPoolId: String(process.env.NEXT_PUBLIC_USER_POOL_ID),
userPoolClientId: String(process.env.NEXT_PUBLIC_USER_POOL_CLIENT_ID),
},
}; |
Hey @CarlWangMK thanks for providing the repo. Our team will try to reproduce the issue with the repo you've provided. We appreciate your patience. |
Hey all - has there been any developments on this? |
Hey @CarlWangMK, we’re still investigating the issue. Thank you for your understanding and let us know any time if you have more questions. |
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
None
Environment information
Describe the bug
This issue only occurs if
middleware.ts
in thesrc
directory is callingrunWithAmplifyServerContext()
in an async context. In the middleware function, as long asrunWithAmplifyServerContext()
is not executed, this error will not happen.Expected behavior
NextJS app compiles frontend without displaying error
Reproduction steps
npm i next@latest
aws-amplify
and@aws-amplify/adapter-nextjs
to latest (optional)npm run dev
Code Snippet
In
middleware.ts
:In
amplify-server-utils
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
I found that downgrading NextJS version 15 makes this issue goes away, to something like version 14, but I would prefer to not do this.
The text was updated successfully, but these errors were encountered: