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

Big Performance dropdown with middleware, latest nextjs and node version >=16.17.1 #42225

Closed
1 task done
11koukou opened this issue Oct 31, 2022 · 7 comments · Fixed by #42547
Closed
1 task done

Big Performance dropdown with middleware, latest nextjs and node version >=16.17.1 #42225

11koukou opened this issue Oct 31, 2022 · 7 comments · Fixed by #42547
Labels
bug Issue was opened via the bug report template.

Comments

@11koukou
Copy link
Contributor

Verify canary release

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

Provide environment information

Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Enterprise LTSC 2021
Binaries:
Node: 16.17.1
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.1-canary.2
eslint-config-next: 12.3.1
react: 18.2.0
react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

After upgrading to latest next 12 canary or next 13 canary version,I have a huge performance drop (middleware enabled). It is pretty obvious when I load my website but also when I run lighthouse which reports a core of 51 instead of ~97 that i reported before the upgrade. If I either switch to latest next stable release or disable the middleware performance returns to normal levels. The same happens if I downgrade my nodejs version to 16.5.0 and keep the middleware and latest nextjs

related to #41551 , #38273

Expected Behavior

Performance should be kept high regardless nodejs version and middleware usage

Link to reproduction

https://github.com/11koukou/my-app

To Reproduce

Simply clone the project, npm install, npm run build, and npm start. Check out the performance and then disable/delete the "middleware.ts" file , repeat the steps and check the performance again. Without middleware lighthouse reports 100. The same happens if you just downgrade to next version 12.3.1 and keep the middleware enabled, or downgrade to nodejs 16.5.0 and keep the middleware and latest nextjs as well

@11koukou 11koukou added the bug Issue was opened via the bug report template. label Oct 31, 2022
@11koukou
Copy link
Contributor Author

11koukou commented Nov 2, 2022

Any news on this? It is really hurting performance

@11koukou
Copy link
Contributor Author

11koukou commented Nov 2, 2022

Everything starts with next version 12.3.2-canary.29

Prior to this everything works fine.

Next 12.3.1 :
Untitled2

Next 12.3.2-canary.29 :
Untitled

Same machine, same node version

@michalwarda
Copy link

I think it's also related to: #42349

@weskor
Copy link

weskor commented Nov 2, 2022

I also have this issue. One thing that really improved my performance for me was by adding:

export const config = { matcher: '/about/:path*', }

The documentation states: Middleware will be invoked for every route in your project. Specifying specific routes seems to improve it greatly.
Performance is still not as good as it is when removing middleware but it did make lighthouse green again. Hope this helps.

@11koukou
Copy link
Contributor Author

11koukou commented Nov 2, 2022

I also have this issue. One thing that really improved my performance for me was by adding:

export const config = { matcher: '/about/:path*', }

The documentation states: Middleware will be invoked for every route in your project. Specifying specific routes seems to improve it greatly. Performance is still not as good as it is when removing middleware but it did make lighthouse green again. Hope this helps.

Thanks for your response, however I notice the same slow behavior even if I use middleware without any code at all inside the exported function

ijjk added a commit that referenced this issue Nov 6, 2022
Follow-up to #41402 this
re-enables the sandbox cache and updates to leverage our global
`AsyncLocalStorage` for isolating request meta in both the edge and
Node.js runtime.

Closes: #42349
Closes: #38235
Closes: #42225
Closes: #42351

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
@ijjk
Copy link
Member

ijjk commented Nov 8, 2022

The above patch is now available in v13.0.3-canary.1 of Next.js, please update and give it a try!

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2022

This closed issue has been automatically locked because it had no new activity for a month. 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 Dec 8, 2022
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants