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

[NEXT-1032] A Node.js API is used (process.turbopack at line: 47) which is not supported in the Edge Runtime. #48302

Closed
1 task done
TrevorThomp opened this issue Apr 12, 2023 · 16 comments
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js. Turbopack Related to Turbopack with Next.js.

Comments

@TrevorThomp
Copy link

TrevorThomp commented Apr 12, 2023

Verify canary release

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

Provide environment information

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:43 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8112
    Binaries:
      Node: 19.7.0
      npm: 9.5.0
      Yarn: 3.5.0
      pnpm: N/A
    Relevant packages:
      next: 13.3.0
      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)

Middleware / Edge (API routes, runtime)

Link to the code that reproduces this issue

https://github.com/TrevorThomp/nextjs-auth-repro

To Reproduce

# Make sure you are on latest Yarn version (>2.0.0).
yarn set version stable

# Install dependencies specified in package.json
yarn install

# Build the application
yarn build

# Build Docker container
yarn docker:build

Describe the Bug

When building the Next application through next build the following output occurs and will fail my builds in GCP:
Error

I raised this issue with Nextjs-Auth0 and they directed me back to here
auth0/nextjs-auth0#1152

The changes that started throwing this error was in the 13.3.0 release:
#47715
d71cbe9#diff-88cc5222d0ce7e563716eee434a1045d101b0043afd2450d66c9eb1ca4ac5cbb

Expected Behavior

Middleware with auth works as expected.

Which browser are you using? (if relevant)

N/A

How are you deploying your application? (if relevant)

N/A

NEXT-1032

@TrevorThomp TrevorThomp added the bug Issue was opened via the bug report template. label Apr 12, 2023
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Apr 12, 2023
@kingb

This comment was marked as off-topic.

@semy
Copy link

semy commented Apr 18, 2023

I have the same error with next-auth

@balazsorban44 balazsorban44 added Turbopack Related to Turbopack with Next.js. kind: bug labels Apr 18, 2023
@balazsorban44 balazsorban44 changed the title A Node.js API is used (process.turbopack at line: 47) which is not supported in the Edge Runtime. [NEXT-1032] A Node.js API is used (process.turbopack at line: 47) which is not supported in the Edge Runtime. Apr 18, 2023
@eblanchette
Copy link

I think I'm getting something related when I add the next-auth/middleware.

middleware.ts

export { default } from "next-auth/middleware";
export const config = { matcher: ["/admin/:path*", "/api/:path*"] };

Error:

[Error: ENOENT: no such file or directory, open '/app/apps/console/.next/server/edge-chunks/wasm_ef4866ecae192fd87727067cf2c0c0cf9fb8b020.wasm']

Can we disable the edge runtime completely when building a standalone app?

@TrevorThomp
Copy link
Author

TrevorThomp commented Apr 19, 2023

I think I'm getting something related when I add the next-auth/middleware.

middleware.ts

export { default } from "next-auth/middleware";
export const config = { matcher: ["/admin/:path*", "/api/:path*"] };

Error:

[Error: ENOENT: no such file or directory, open '/app/apps/console/.next/server/edge-chunks/wasm_ef4866ecae192fd87727067cf2c0c0cf9fb8b020.wasm']

Can we disable the edge runtime completely when building a standalone app?

I saw that issue as well in GCP logs on builds so it could definitely be related.

@GeorgEchterling
Copy link

GeorgEchterling commented Apr 19, 2023

I think I'm getting something related when I add the next-auth/middleware.

middleware.ts

export { default } from "next-auth/middleware";
export const config = { matcher: ["/admin/:path*", "/api/:path*"] };

Error:

[Error: ENOENT: no such file or directory, open '/app/apps/console/.next/server/edge-chunks/wasm_ef4866ecae192fd87727067cf2c0c0cf9fb8b020.wasm']

Can we disable the edge runtime completely when building a standalone app?

I looks like the edge-chunks directory doesn't get generated for the standalone build. It is generated at .next/server/edge-chunks, but not at .next/standalone/.next/server/edge-chunks, just like the static directory.

As a workaround, I've added the following line to the Dockerfile:

COPY --from=builder --chown=nextjs:nodejs /app/.next/server/edge-chunks ./.next/server/edge-chunks

This handles the edge-chunks directory in the same way as the static Directory in the Docker example. It removes the [Error: ENOENT: no such file or directory, open '/app/apps/console/.next/server/edge-chunks/wasm_ef4866ecae192fd87727067cf2c0c0cf9fb8b020.wasm'] runtime error.

I'm guessing that these WASM chunks are related to the image-response stuff, which is meant to be removed during tree shaking. So this is only a workaround, not an actual fix.

@eblanchette
Copy link

@GeorgEchterling THANKS! It's working now

@Defrosted
Copy link

Having the same issue with the edge-chunks directory not being copied over, but I'm using SST and Open Next to build. Was able to solve this for now by modifying my next build script to be next build && cp -r .next/server/edge-chunks .next/standalone/.next/server/edge-chunks.

@abepuentes
Copy link

abepuentes commented Apr 20, 2023

Same error here using next-intl/middleware.

import createMiddleware from "next-intl/middleware";

export default createMiddleware({
  locales: ["en", "es"],
  defaultLocale: "en",
});

export const config = {
  // Skip all paths that should not be internationalized
  matcher: ["/((?!_next|.*\\..*).*)"],
};

@Defrosted thanks, your workaround was useful to deploy to amplify hosting (using an amplify.yml). Although AppDir is working fine on amplify hosting I wonder about the performance using SST, the cold start of almost 10seconds is a bit annoying. can you tell me if its better on SST?

@Defrosted
Copy link

Same error here using next-intl/middleware.

import createMiddleware from "next-intl/middleware";

export default createMiddleware({
  locales: ["en", "es"],
  defaultLocale: "en",
});

export const config = {
  // Skip all paths that should not be internationalized
  matcher: ["/((?!_next|.*\\..*).*)"],
};

@Defrosted thanks, your workaround was useful to deploy to amplify hosting (using an amplify.yml). Although AppDir is working fine on amplify hosting I wonder about the performance using SST, the cold start of almost 10seconds is a bit annoying. can you tell me if its better on SST?

10 seconds sounds quite extreme. Not sure if SST would be able to help with that if the underlying cause is somewhere else. My guess would be that Amplify uses a similar infrastructure with Lambdas under the hood. The nice side with SST is that you're in control of the infrastructure. I haven't personally seen that high cold starts so far.

@Kiborgik
Copy link

the same for me

@Defrosted
Copy link

Sharing this here as well: There was a discussion in #48638 regarding this, and there's now PR #48723 that attempts to fix this to my understanding.

@CKGrafico
Copy link

CKGrafico commented May 3, 2023

I confirm that @Defrosted comment mentioning a PR is fixing this, works fine in "13.3.5-canary.5" to me

@belgattitude
Copy link
Contributor

belgattitude commented May 5, 2023

After upgrade to nextjs 13.4.0 (from 13.3.4)

Vercel started to fail at build time with a similar message. Vercel is configured to use Node 18.x

image

The example repo is:

https://github.com/belgattitude/nextjs-monorepo-example (branch main)

(no-app-dir)

The ci passes (build on node works) on main, vercel just started to break after upgrade.

If you want to try on vercel, you'll have to add ENABLE_EXPERIMENTAL_COREPACK=1 in the vercel env.

Open to help if needed

@GeorgEchterling
Copy link

Looks like this has been fixed as of version 13.4.7. The process.turbopack warning no longer appears and the edge-chunks directory is no longer necessary.

@ForsakenHarmony
Copy link
Member

Closing this as it's very old and probably fixed, feel free to open a new issue

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests