stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.95k stars 176 forks source link

Next.js 13 APP directory cookies don't work on stackblitz. #1109

Open prepr-io opened 1 year ago

prepr-io commented 1 year ago

Describe the bug

Hello,

We have encountered a bug when trying to load our Next 13 App project into Stackblitz. In a file we make use of the cookies function from next/headers. But on stackblitz this produces an error. See the screenshot provided.

- error node_modules/next/dist/client/components/headers.js (50:14) @ cookies
- error Error: Invariant: Method expects to have requestAsyncStorage, none available
    at ABTestingPage (./src/app/a-b-testing/page.js:40:78)
    at async Promise.all (index 0)
    at async Promise.all (index 0)

Link to the blitz that caused the error

https://stackblitz.com/edit/nextjs-starter-prepr-cms?file=README.md,src%2Fapp%2Fa-b-testing%2Fpage.js

Steps to reproduce

  1. Go to the stackblitz with the url provided
  2. In the preview open the navigation menu and navigate to the a-b-testing page
  3. The page will not load and produce the specified error.

Expected behavior

I would expect the native functions of Next.js to work.

Parity with Local

Screenshots

image

Platform

Browser name  = Chrome
Full version  = 114.0.0.0
Major version = 114
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 105366632,
  "usedJSHeapSize": 100216516,
  "jsHeapSizeLimit": 4294705152
}
Hash = 131c0a4f

Additional context

No response

jrvidal commented 1 year ago

@prepr-io :wave: Thanks for the report. TL,DR: we don't support async_hooks or AsyncLocalStorage.

This is something that is in our radar (though it's very difficult to implement properly), so we can leave this issue open in case you want updates if/when there's any progress on that front.