Skip to content

[NEXT-644] cookies broke on 13.2.1 Invariant: Method expects to have requestAsyncStorage, none available #46356

@cipriancaba

Description

@cipriancaba

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: linux
Arch: x64
Version: Ubuntu 20.04.0 LTS Fri Feb 24 2023 12:23:18 GMT+0200 (Eastern European Standard Time)
Binaries:
Node: 16.14.2
npm: 7.17.0
Yarn: 1.22.19
pnpm: 7.13.6
Relevant packages:
next: 13.2.1
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue

https://stackblitz.com/edit/vercel-next-js-gqeapg?file=package.json,app%2F[variant]%2F(shop)%2Fp%2F[[...id]]%2Fpage.tsx,next.config.js

To Reproduce

Try to import cookies from next/headers
Try to access a dynamic page, eg /test/p

Describe the Bug

Error: Invariant: Method expects to have requestAsyncStorage, none available

This happens if I do an import of cookies

import { cookies } from 'next/headers';

const DynamicPage = async () => {
  const nextCookies = cookies();
  console.log(nextCookies.get('random'));
  const data = await loadRandomData();

  return <div>{data.title}</div>;
};

Screenshot 2023-02-24 at 12 26 31

Expected Behavior

I can access the cookies object on a dynamic page

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-644

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions