[async_wrap] fix fatal error during destroy() calls
Checklist
-
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
async_wrap
Description of change
Calling JS during GC is a no-no. So intead create a queue of all ids that need to have their destroy() callback called and call them later.
Removed checking destroy() in test-async-wrap-uid because destroy() can be called after the 'exit' callback.
Missing a reliable test to reproduce the issue that caused the FATAL_ERROR.
Fixes: https://github.com/nodejs/node/issues/8216 Fixes: https://github.com/nodejs/node/issues/9465
R=@bnoordhuis