-
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
When a client made by generateServerClientUsingCookies is used in a server action it mutates cookies #13787
Comments
Hi @Aldo-Garza 👋 thanks for raising this issue and providing reproduction steps! I will attempt to reproduce the behavior and update this issue accordingly for the team to take action |
Hi all, this cookie mutation is an expected behavior given current implementation of the credentials fetching logic. We will look into this. |
To add to what @HuiSF said, this appears to be expected behavior. However, we'll mark this as a feature request at this point to explore other/better options for how we're handling the Identity Id every time the credentials are refreshed. |
Hi @Aldo-Garza we've released a change to remove this redundant |
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
GraphQL API, DataStore
Amplify Version
v6
Amplify Categories
storage
Backend
Amplify Gen 2 (Preview)
Environment information
Describe the bug
In nextjs, if a server action is called, and such server action fetches any data from a model like for example the following:
It causes a mutation on the cookies (it deletes a cookie), such cookie looks like:
This causes unexpected behaviours in nextjs, since the cookie is beign mutated it ends up causing a refresh of the server component
Expected behavior
It should not mutate the cookies.
I fixed it by patching the delete method of cookies()
Reproduction steps
1- Create a server component which reads some data for display
2- Inside the server component add a button which calls a server action, such server action must use the cookies client for calling list() on a model for example
3- When calling the server action it will cause the cookies to be mutated which will make the server component to re-render (refresh) even though nothing was changed.
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
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
No response
The text was updated successfully, but these errors were encountered: