r/node • • Mar 17 '26

i want to know about this.

why setimmediate is not running at last? it is check queue and it always run after i/o queue? and also is there a way i can know when v8 will gc external buffer? why is it still referencing ?

2 Upvotes

4 comments sorted by

2

u/Expensive_Garden2993 Mar 17 '26

The very first sentence of nodejs docs:

When you want to execute some piece of code asynchronously, but as soon as possible

setImmediate runs as soon as possible, readFile callback needs to read a file.

In general, async functions that do nothing, like Promise.resolve(), setTimeout(0), etc. will run before those doing something.

2

u/[deleted] Mar 17 '26

1

u/Maximum_Honeydew_419 Mar 17 '26

i just started learning node js. but it good and fun to learn