为什么VS Code在使用步骤时会进入Node.js内部代码

时间:2017-06-16 05:28:12

标签: javascript node.js visual-studio-code

在此示例代码中进行调试,并且每次按f10(跳过),调试器将输入文件名next_tick.js,这是一个与Node.js相关的文件。为什么?我不想进入与Node.js相关的内部代码。

以下是示例代码

function abc() {
 return new Promise((resolve, reject) => {
    setTimeout(function () { resolve(10) }, 1000)
  });
}

async function b(){
  const a=10+ await abc()
  console.log(a)
}

b()

以下是next_tick.js的一部分

// Run callbacks that have no domain.
  // Using domains will cause this to be overridden.
  function _tickCallback() {
    do {
      while (tickInfo[kIndex] < tickInfo[kLength]) {
        const tock = nextTickQueue[tickInfo[kIndex]++];
        const callback = tock.callback;
        const args = tock.args;

        // CHECK(Number.isSafeInteger(tock[async_id_symbol]))
        // CHECK(tock[async_id_symbol] > 0)
        // CHECK(Number.isSafeInteger(tock[trigger_id_symbol]))
        // CHECK(tock[trigger_id_symbol] > 0)

        nextTickEmitBefore(tock[async_id_symbol], tock[trigger_id_symbol]);
        // emitDestroy() places the async_id_symbol into an asynchronous queue
        // that calls the destroy callback in the future. It's called before
        // calling tock.callback so destroy will be called even if the callback
        // throws an exception that is handles by 'uncaughtException' or a
        // domain.
        // TODO(trevnorris): This is a bit of a hack. It relies on the fact
        // that nextTick() doesn't allow the event loop to proceed, but if
        // any async hooks are enabled during the callback's execution then
        // this tock's after hook will be called, but not its destroy hook.
        if (async_hook_fields[kDestroy] > 0)
          emitDestroy(tock[async_id_symbol]);

        // Using separate callback execution functions allows direct
        // callback invocation with small numbers of arguments to avoid the
        // performance hit associated with using `fn.apply()`
        _combinedTickCallback(args, callback);

        nextTickEmitAfter(tock[async_id_symbol]);

        if (kMaxCallbacksPerLoop < tickInfo[kIndex])
          tickDone();
      }
      tickDone();
      _runMicrotasks();
      emitPendingUnhandledRejections();
    } while (tickInfo[kLength] !== 0);
  }

0 个答案:

没有答案