vercel / next.js

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

Internal server error in website with adgroupid in params, when using middleware and ad-blocker #40093

Open gerdazk opened 2 years ago

gerdazk commented 2 years ago

Verify canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101
    Binaries:
      Node: 16.13.0
      npm: 8.1.0
      Yarn: 1.22.15
      pnpm: N/A
    Relevant packages:
      next: 12.2.6-canary.6
      eslint-config-next: 12.2.5
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome 104.0.0.0

How are you deploying your application? (if relevant)

No response

Describe the Bug

Nextjs app breaks when i use middleware + ad-blocker

I have added middleware.ts file to a new nextjs project. When I use ad-blocker and visit url with adgroupid in the params (e.g. http://localhost:3000/test?id=9&adgroupid=292929), I get 500 error and app crashes.
Everything works fine when ad-blocker is not used.

Ad-blockers that i have used: Adblock-plus
Ublock

Expected Behavior

App does not crash and content is displayed

If I visit website with adgroupid in parameters (http://localhost:3000/test?id=9&adgroupid=292929), do not add middleware and use ad-blocker, I can see in the console that some requests are blocked, but it does not cause 500 error and my app is still displayed. This would be the expected behaviour with middleware used as well.

Link to reproduction

https://github.com/gerdazk/nextjs-middleware-bug

To Reproduce

Clone the repository Run yarn install Run yarn dev Visit http://localhost:3000/test?id=9&adgroupid=292929 'Failed to fetch' error should show up.

Or:

Clone the repository Run yarn install Run yarn build Run yarn start Visit http://localhost:3000/test?id=9&adgroupid=292929 'Internal server error' message should show up

andrewnick commented 2 years ago

I am also receiving these errors. Certain utm_content parameter values are blocked by Adblock Plus. This is only happening on dynamic pages as the add blocker is blocking the additional fetch for page data as the tracking parameters are present on the path.

Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000
    Binaries:
      Node: 14.18.2
      npm: 6.14.15
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 12.2.4
      eslint-config-next: 11.1.0
      react: 17.0.2
      react-dom: 17.0.2