async_wrap: close the destroy_ids_idle_handle_ on environment destruction
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines
Affected core subsystem(s)
async_wrap
Description of change
The destroy_ids_idle_handle_
is currently not getting closed in the environment destructor. After the environment has been destroyed, the uv loop used by the environment contains a dangling pointer in the handle list which leads to undefined behavior when the loop is still being used.
This is currently no issue for the "main" uv loop used by node. However if an embedder creates his own environment this will most likely lead to crashes. By looking at the code in Environment::Start
it was also not entirely clear for me that destroy_ids_idle_handle_
is not added to the handle cleanup queue by intention.
The additional delayed cleanup queue may be an overkill since it only contains one handle right now, but it seemed to me that it would be the most generic and verbose approach.