Unverified Commit 4d73fd39 authored by Anna Henningsen's avatar Anna Henningsen
Browse files

src: run native immediates during Environment cleanup

This can be necessary, because some parts of the Node.js code base
perform cleanup operations in the Immediate callbacks, e.g. HTTP/2.

This resolves flakiness in an HTTP/2 test that failed when a
`SetImmediate()` callback was not run or destroyed before the
`Environment` destructor started, because that callback held a
strong reference to the `Http2Session` object and the expectation
was that no such objects exist once the `Environment` constructor
starts.

Another, slightly more direct, alternative would have
been to clear the immediate queue rather than to run it. However,
this approach seems to make more sense as code generally assumes
that the `SetImmediate()` callback will always run; For example,
N-API uses an immediate callback to call buffer finalization
callbacks.

Unref’ed immediates are skipped, as the expectation is generally
that they may not run anyway.

Fixes: https://github.com/nodejs/node/issues/30643

PR-URL: https://github.com/nodejs/node/pull/30666
Refs: https://github.com/nodejs/node/pull/30374


Reviewed-By: default avatarRich Trott <rtrott@gmail.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
parent 4c9db6c7
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