vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.39k stars 26.78k forks source link

Middleware causing duplicate /GET logs #60992

Open jordanpurinton opened 8 months ago

jordanpurinton commented 8 months ago

Link to the code that reproduces this issue

https://github.com/jordanpurinton/next-middleware-dupe-logging

To Reproduce

  1. Start app using npm run dev
  2. Hit http://localhost:3000 in the browser
  3. Observe multiple GETs in the next logs (with fullUrl: true)

Current vs. Expected behavior

This happens in a larger app I'm working on, but even using create next app I'm seeing duplicate logs for GET/POST requests on routes in my application when using middleware. This behavior seems to go away when turning off the middleware.

Why are these logs being omitted more than once? Ideally, I would only see one request being omitted in the logs, however there are multiple GET requests omitted.

Why is this the case when using middleware? Is there something I'm missing or misunderstanding here?

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.5.0
Binaries:
  Node: 18.17.0
  npm: 9.6.7
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

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

App Router, Middleware / Edge (API routes, runtime)

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

next dev (local)

Additional context

Screenshot 2024-01-22 at 10 31 01 AM
kadirselki commented 8 months ago

I have been experiencing this issue since Next.js version 13. Has there been any progress on this matter?

Screenshot 2024-01-27 at 13 05 35
davecarlson commented 5 months ago

Confirm I too see this. with no middleware.ts: 1 log with middleware.ts file with an empty function: 2 logs

@leerob

cayasso commented 5 months ago

This seems to be fixed in 14.2.2