Next.js Discord

Discord Forum

The event loop triggers the microtask queues in different order in NextJS

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
If you run this snippet in Node

Promise.resolve().then(() => console.log("resolve"))
    process.nextTick(() => console.log("Tick"))

Tick
resolve

is what you will see in the console.

But in NextJS

export const getStaticProps = () => {

  

    Promise.resolve().then(() => console.log("resolve"))
    process.nextTick(() => console.log("Tick"))
  

    return {
        props: {}
    }
}

resolve
Tick

is printed out in that order, even if you move it to the component. Why are the printing orders for both NodeJS and NextJS different?

3 Replies

Transvaal lionOP
bump
Transvaal lionOP
bump
Transvaal lionOP
bump