With the lastest nextjs version, redirect from a server action cause an error due to cookie state.
Cookie state json encoding seems to be broken at some point.
Stack trace:
⨯ SyntaxError: Unexpected token '%', "%7B%22stat"... is not valid JSON
at JSON.parse ()
at RootLayout (./src/app/layout.tsx:29:85)
at stringify ()
at AsyncLocalStorage.run (node:async_hooks:346:14)
Link to minimal reproducible example
https://wagmi-redirect-error-nextjs-production.up.railway.app/
Summary
With the lastest nextjs version, redirect from a server action cause an error due to cookie state. Cookie state json encoding seems to be broken at some point.
Source repo : https://github.com/jpcrinon/wagmi-redirect-error-nextjs
Stack trace: ⨯ SyntaxError: Unexpected token '%', "%7B%22stat"... is not valid JSON at JSON.parse ()
at RootLayout (./src/app/layout.tsx:29:85)
at stringify ()
at AsyncLocalStorage.run (node:async_hooks:346:14)
List of related npm package versions
"dependencies": { "@tanstack/react-query": "^5.32.0", "@web3modal/wagmi": "^4.1.11", "next": "^14.2.3", "react": "18.2.0", "react-dom": "18.2.0", "viem": "^2.9.28", "wagmi": "^2.7.0" }, "devDependencies": { "@types/node": "20.11.5", "@types/react": "18.3.1", "eslint": "8.56.0", "eslint-config-next": "14.1.0", "typescript": "5.3.3" }