Invariant: cookies() expects to have requestAsyncStorage, none available.
Answered
Somebody posted this in #help-forum
SomebodyOP
Is
Could it be a missing dependency or something?
cookies()
not supported on the edge runtime? The docs make it seem like it is (although it isn't clarified), however I'm getting this error when trying to run my application locally.Could it be a missing dependency or something?
25 Replies
European sprat
What version of next
SomebodyOP
latest
13.4.19
European sprat
i just tried on a route handler where i set it to
const runtime = "edge"
and reading cookies workedwhere are you trying to read them?
SomebodyOP
in the root layout
it works with the nodejs runtime, but not with the edge runtime
I'm calling cookies() in the root layout, then pass the return value to a client component, which is a context provider to pass them to other components.
Apparently this worked in 13.2.0, according to a github issue
SomebodyOP
It works in 13.4.7 too, just tested it out
European sprat
i just tried a new create-next-app at it works
SomebodyOP
broken in 13.4.17 and 13.4.19
European sprat
all i did was add the runtime export and logged out the cookies and i can see them
tested with prod build too
SomebodyOP
I'll try to reproduce it with a smaller code base
SomebodyOP
Still happening with only this code:
Full project in the zip file.
// app/layout.tsx
import { Noto_Sans } from "next/font/google";
import { cookies } from "next/headers";
const font = Noto_Sans({
weight: ["200", "300", "400"],
subsets: ["latin"],
});
export const runtime = "edge";
const RootLayout = async ({ children }: { children: React.ReactNode }) => {
cookies();
return (
<html lang="en">
<body className={font.className}>{children}</body>
</html>
);
};
export default RootLayout;
// app/page.tsx
export default function Dashboard() {
return <div>Dashboard</div>;
}
Full project in the zip file.
SomebodyOP
Next Info:
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 18.13.0
npm: 8.1.4
SomebodyOP
Issue I found: https://github.com/vercel/next.js/issues/52176
Answer
European sprat
Ah so it's a windows issue
SomebodyOP
Seems like it's tracked since yesterday
Thank you for your time
Norwegian Forest Cat
is there any solution for this? im still facing this issue on windows
SomebodyOP
it's still broken.
using 13.4.7 is the only solution I know of
using 13.4.7 is the only solution I know of