WalletConnect / web3modal

A single Web3 provider solution for all Wallets
https://web3modal.com
Apache License 2.0
4.67k stars 1.28k forks source link

[bug] NextJs 14.2 - Redirect error from server action due to cookie storage #2197

Open jpcrinon opened 2 weeks ago

jpcrinon commented 2 weeks ago

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" }

linear[bot] commented 2 weeks ago

W3M-306 [bug] NextJs 14.2 - Redirect error from server action due to cookie storage