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

Error during dev and warning at build in middleware.ts with --turbo flag #75280

Open
sommeeeer opened this issue Jan 24, 2025 · 1 comment
Open
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Middleware Related to Next.js Middleware. Runtime Related to Node.js or Edge Runtime with Next.js. Turbopack Related to Turbopack with Next.js.

Comments

@sommeeeer
Copy link
Contributor

Link to the code that reproduces this issue

https://github.com/sommeeeer/next-middleware-edge-turbo-node

To Reproduce

  1. start the dev server with pnpm dev
  2. open up http://localhost:3000 and look for the request header: hello-from-function.
  3. close the dev server and now run it with --turbo flag: pnpm devturbo

Current vs. Expected behavior

Image

So the src/lib/node-native.ts exports two functions. One is for the middleware.ts and the other one is a random async hi() function that dynamically imports a native Node.js API from fs/promises.

Since we are not using this function in the middleware it should not be flagged. I think it should work the same way as normal next dev without the --turbo flag.

Can note that next build works but with warnings.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #47~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct  2 16:16:55 UTC 2
  Available memory (MB): 14800
  Available CPU cores: 16
Binaries:
  Node: 20.18.0
  npm: 10.9.1
  Yarn: 1.22.19
  pnpm: 9.15.4
Relevant Packages:
  next: 15.1.6 // Latest available version is detected (15.1.6).
  eslint-config-next: 15.1.6
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack, Middleware

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

No response

@github-actions github-actions bot added Middleware Related to Next.js Middleware. Turbopack Related to Turbopack with Next.js. labels Jan 24, 2025
@samcx samcx added the Runtime Related to Node.js or Edge Runtime with Next.js. label Jan 28, 2025
@samcx
Copy link
Member

samcx commented Jan 29, 2025

@sommeeeer Thank you for submitting an issue!

Taking a look 👁

@samcx samcx added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Middleware Related to Next.js Middleware. 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

2 participants