Turbopack causes `req instanceof NextRequest` to fail in `nodejs` middleware
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/SimonVadier/repro-turbopack-nodejs-middleware
To Reproduce
- Start the application with
next dev - Visit the app
- Observe console log
Request is an instance of NextRequest - Start the application with
next dev --turbopack - Visit the app
- Observe console log
Request is not an instance of NextRequest
Current vs. Expected behavior
When using Turbopack in dev mode, request instanceof NextRequest returns false in a nodejs middleware, while it returns true with the standard dev server. This is problematic because some libraries rely on this check to determine how to process the request object. (https://github.com/auth0/nextjs-auth0/issues/2253)
The request object provided by Turbopack seems to have the same shape and functionality as NextRequest, but it fails the instanceof check.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Thu Aug 21 06:22:32 EDT 2025
Available memory (MB): 15732
Available CPU cores: 12
Binaries:
Node: 24.5.0
npm: 11.5.1
Yarn: 1.22.22
pnpm: 10.14.0
Relevant Packages:
next: 15.5.2 // Latest available version is detected (15.5.2).
eslint-config-next: N/A
react: 19.1.1
react-dom: 19.1.1
typescript: N/A
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Middleware
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Turbopack reproduction and compare next dev with next dev --turbopack for the nodejs middleware case. Trace where the middleware request is constructed, then verify that req instanceof NextRequest is true under both dev servers and add a regression test if the relevant test location is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs, nodejs
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100