Skip to content

async hooks promise not destroyed #14446

Description

@wengeezhang
  • 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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions