Next.js Discord

Discord Forum

Next.js event loop lag is high

Unanswered
Florida White posted this in #help-forum
Open in Discord
Florida WhiteOP
I wrote a simple Next.js app that returns an empty page and I try to measure the lag of event loop using

function measureLag(iteration) {
const start = new Date() setTimeout(() => {
const lag = new Date() - startconsole.log(Loop ${iteration} took\t${lag} ms) measureLag(iteration + 1) // Recurse
})
}
measureLag(1)

For the first 3 seconds, the lag is 1 ms, then it jumps to 15 ms (or greater).
Is this an expected behavior?
Profiling with https://github.com/naugtur/blocked-at seems pointing to some bottleneck inside webpack/bundle5
I'm not anexpert, but this seems to me really strange.
I would expect no lag on event loop for this kind of application

4 Replies

Florida WhiteOP
I can say that the lag is high on Windows 11, and seems ok on Windows 10.
It seems that Windows 11 has a 15 ms lag (almost at every loop)
even if I use setTimeout with a long timeout (100 ms) I see that I have 115 ms (almost constant)
do you know why?