-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Bug report
Describe the bug
Hi,
I found this bug in my Next.js app, but we think it's not related to NextJS itself but rather SSR in general.
Let's go straight to example:
To Reproduce
- clone this repo - https://github.com/RafalFilipek/nextjs-react-spring-bug
yarn installyarn buildyarn start
This command will start production version of application with --inspect flag to enable NodeJs debugger.
- open
[http://localhost:3000](http://localhost:3000)in Chome - open DevTools and click NodeJS logo on the left
This will open Dedicated NodeJS debugger.
- open
Memorytab, selectHeap Snapshotand clickTake Snapshot. You will get something like this:
Now it's time to make some requests. I'm using autocannon, but you can use any tool like ab.
autocannon -c 50 -a 1000 http://localhost:3000
Now you can take second snapshot. It should be much bigger:
After 4K requests you will see that there is a lot of allocations in array part. For some reason there are many allocations of Controller class from react-spring. I have no idea why.
It looks like new Controller class is created for each request, but old instances are not garbage collected. (this and this lines?)
Now let's compare snapshots in this same application but without getInitialProps in _app.js - no SRR.
After 10K request you will get something like this:
Snapshot 1- afteryarn startSnapshot 2- after 10K reqSnapshot 3- afterGC
System information
- OS: macOs / Docker 12.4.0-alpine
- Version of Next.js:
9.0.2,9.0.3 - Version of react-spring
8.0.27,9.0.0-beta.31 - Version of React:
16.8.6
Thank you




