async hooks promise not destroyed
- Version: node -v 8.2.1
- Platform: window 7 64-bit
- Subsystem:
my code is like follows:
const async_hooks = require('async_hooks'); function init(id, type, triggerId, handle) { process._rawDebug(`id: ${id}, type: ${type}, triggerId: ${triggerId}, handle.promise: ${handle.promise}, handle.parentid: ${handle.parentId}`); } function before(id) { process._rawDebug('before', id, async_hooks.executionAsyncId()); } function after(id) { process._rawDebug('after', id, async_hooks.executionAsyncId()); } function destroy(id) { process._rawDebug('destroy', id); } async_hooks.createHook({init, before, after, destroy}).enable(); debugger; const parent_promise = new Promise((resolve, reject) => {resolve(5);}); const promise = parent_promise.then((val) => {return val;});
the output is:
id: 2, type: PROMISE, triggerId: 1
id: 3, type: PROMISE, triggerId: 2
before 3 3
after 3 3
why the Promise async resources' destroy callback not triggered?