Skip to content

async-wrap: nextTick and setImmediate is ignored #666

Closed
@AndreasMadsen

Description

@AndreasMadsen

Here is a test case you can run with node 0.11.14 and iojs 1.0.x.

var fs = require('fs');
function writeSync(text) { fs.writeSync(1, text + '\n'); fs.fsyncSync(1); }
Error.stackTraceLimit = Infinity;

// Enable asyncWrap and call init hook function on async initialization
try {
  var tracing = require('tracing');
  // Setup an async listener with the handlers listed below
  tracing.addAsyncListener({
    'create': asyncFunctionInitialized,
    'before': asyncCallbackBefore,
    'error': asyncCallbackError,
    'after': asyncCallbackAfter
  });
} catch (e) {
  var asyncWrap = process.binding('async_wrap');
  var asyncHooksObject = {};
  var kCallInitHook = 0;
  asyncWrap.setupHooks(
    asyncHooksObject,
    asyncFunctionInitialized,
    asyncCallbackBefore,
    asyncCallbackAfter);
  asyncHooksObject[kCallInitHook] = 1;
}

function asyncFunctionInitialized() {
  writeSync((new Error()).stack);
}
function asyncCallbackBefore() {}
function asyncCallbackError() {}
function asyncCallbackAfter() {}

// TEST
(function outer() {
  setImmediate(function () {
    writeSync('END');
  });
})();

In the node 0.11.14 asyncFunctionInitialized is called and the stack trace is printed. However in iojs 1.0.x just END is printed. This also seams to be the case for process.nextTick.

issue tracing: AndreasMadsen/trace#12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions