Unverified Commit 2cedff9c authored by Anna Henningsen's avatar Anna Henningsen
Browse files

src: cancel pending delayed platform tasks on exit

Worker threads need an event loop without active libuv handles in
order to shut down. One source of handles that was previously
not accounted for were delayed V8 tasks; these create timers
that would be standing in the way of clearing the event loop.

To solve this, keep track of the scheduled tasks in a list
and close their timer handles before the corresponding isolate/loop
is removed from the platform.

It is not clear from the V8 documentation what the expectation is
with respect to pending background tasks at the end of the
isolate lifetime; however, an alternative approach of executing
these scheduled tasks when flushing them led to an infinite loop
of tasks scheduling each other; so it seems safe to assume that
the behaviour implemented in this patch is at least acceptable.

Original-PR-URL: https://github.com/ayojs/ayo/pull/120


Original-Reviewed-By: default avatarStephen Belanger <admin@stephenbelanger.com>
PR-URL: https://github.com/nodejs/node/pull/16700


Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
parent c7ad7290
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment