Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[turbopack] Invariant: AsyncLocalStorage accessed in runtime where it is not available #3319

Closed
pan93412 opened this issue Jan 15, 2023 · 19 comments · Fixed by #3374 · 4 remaining pull requests
Closed

[turbopack] Invariant: AsyncLocalStorage accessed in runtime where it is not available #3319

pan93412 opened this issue Jan 15, 2023 · 19 comments · Fixed by #3374 · 4 remaining pull requests
Assignees
Labels
kind: bug Something isn't working

Comments

@pan93412
Copy link

pan93412 commented Jan 15, 2023

What version of Turbopack are you using?

next 13.1.2

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Describe the Bug

Turbopack throws the runtime error Invariant: AsyncLocalStorage accessed in runtime where it is not available when attempting to start up a Next.js project with appDir: true. Webpack works as expected.

Expected Behavior

Turbopack should works as what Webpack does.

To Reproduce

  1. Create a Next app with appDir enabled:

image

$ pnpm create next-app@latest
../.pnpm-store/v3/tmp/dlx-90629          |   +1 +
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /Volumes/Dev/.pnpm-store/v3
  Virtual store is at:             ../.pnpm-store/v3/tmp/dlx-90629/node_modules/.pnpm
../.pnpm-store/v3/tmp/dlx-90629          | Progress: resolved 1, reused 0, downloaded 1, added 1, done
✔ What is your project named? … experiments
✔ Would you like to use TypeScript with this project? … No / [Yes]
✔ Would you like to use ESLint with this project? … No / [Yes]
✔ Would you like to use `src/` directory with this project? … No / [Yes]
✔ Would you like to use experimental `app/` directory with this project? … No / [Yes]
Creating a new Next.js app in /Volumes/Dev/Experiments/experiments.

Using pnpm.

Installing dependencies:
- react
- react-dom
- next
- @next/font
- typescript
- @types/react
- @types/node
- @types/react-dom
- eslint
- eslint-config-next

Packages: +267
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /Volumes/Dev/.pnpm-store/v3
  Virtual store is at:             node_modules/.pnpm

dependencies:
+ @next/font 13.1.2
+ @types/node 18.11.18
+ @types/react 18.0.26
+ @types/react-dom 18.0.10
+ eslint 8.32.0
+ eslint-config-next 13.1.2
+ next 13.1.2
+ react 18.2.0
+ react-dom 18.2.0
+ typescript 4.9.4

Progress: resolved 279, reused 267, downloaded 0, added 267, done
Done in 15.2s

Initializing project with template: app 

Initialized a git repository.

Success! Created experiments at /Volumes/Dev/Experiments/experiments
  1. Run pnpm dev --turbo. It throws.

Turbopack

image

image

Webpack

image

Reproduction Repo

No response

@pan93412 pan93412 added area: turbopack kind: bug Something isn't working labels Jan 15, 2023
@beldur
Copy link

beldur commented Jan 15, 2023

I have the same issue

@mrhoodz
Copy link

mrhoodz commented Jan 16, 2023

I have the same issue, started facing it today so probably its a turbopack bug

@BWBama85
Copy link

Same issue

@tarunfy
Copy link

tarunfy commented Jan 17, 2023

Yup, I got the same issue.

@frnikho
Copy link

frnikho commented Jan 17, 2023

Facing the same issue

@EfrainCo
Copy link

Same here

@ghost
Copy link

ghost commented Jan 18, 2023

same :(

@vtassios
Copy link

Same

@aleTornesi
Copy link

Same issue

@DevHigley
Copy link

Same

@anasbayu
Copy link

same

1 similar comment
@ricardosc12
Copy link

same

@kr4chinin
Copy link

Yep, still facing this issue too!

@basmonje
Copy link

Same issue

@jridgewell
Copy link
Contributor

jridgewell commented Jan 18, 2023

Hi all, I'll be addressing this today. It's likely we'll need a new Next.js canary release in order for this to take effect. In the meantime, you should be able to npm install next@13.1.2-canary.2 to temporarily undo the breaking PR

@jridgewell jridgewell self-assigned this Jan 18, 2023
@AttalliAyoub
Copy link

Same issue

@kodiakhq kodiakhq bot closed this as completed in #3374 Jan 19, 2023
kodiakhq bot pushed a commit that referenced this issue Jan 19, 2023
vercel/next.js#44668 refactored Next's use of `AsyncLocalStorage`, and installs a "polyfill" of the API by patching the node import onto `globalThis.` Importantly, it's then used in the module scope during imports, so we need to install the polyfill early in the app rendering startup.

Fixes #3319
@Kenny-24
Copy link

Kenny-24 commented Jan 20, 2023

change the 'next' to 13.1.0 in package.json and pnpm i

@tholder
Copy link

tholder commented Feb 6, 2023

I'm seeing it with 13.1.5

@jridgewell
Copy link
Contributor

@tholder: There was a second issue that we just resolved in #3634. Will be part of the next release.

jridgewell added a commit to vercel/next.js that referenced this issue Mar 10, 2023
#44668 refactored Next's use of `AsyncLocalStorage`, and installs a "polyfill" of the API by patching the node import onto `globalThis.` Importantly, it's then used in the module scope during imports, so we need to install the polyfill early in the app rendering startup.

Fixes vercel/turborepo#3319
sokra pushed a commit to vercel/next.js that referenced this issue Mar 13, 2023
#44668 refactored Next's use of `AsyncLocalStorage`, and installs a "polyfill" of the API by patching the node import onto `globalThis.` Importantly, it's then used in the module scope during imports, so we need to install the polyfill early in the app rendering startup.

Fixes vercel/turborepo#3319
ForsakenHarmony pushed a commit to vercel/next.js that referenced this issue Jul 25, 2024
#44668 refactored Next's use of `AsyncLocalStorage`, and installs a "polyfill" of the API by patching the node import onto `globalThis.` Importantly, it's then used in the module scope during imports, so we need to install the polyfill early in the app rendering startup.

Fixes vercel/turborepo#3319
ForsakenHarmony pushed a commit to vercel/next.js that referenced this issue Jul 29, 2024
#44668 refactored Next's use of `AsyncLocalStorage`, and installs a "polyfill" of the API by patching the node import onto `globalThis.` Importantly, it's then used in the module scope during imports, so we need to install the polyfill early in the app rendering startup.

Fixes vercel/turborepo#3319
ForsakenHarmony pushed a commit to vercel/next.js that referenced this issue Aug 1, 2024
#44668 refactored Next's use of `AsyncLocalStorage`, and installs a "polyfill" of the API by patching the node import onto `globalThis.` Importantly, it's then used in the module scope during imports, so we need to install the polyfill early in the app rendering startup.

Fixes vercel/turborepo#3319
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment