title: Why console.log goes infinite in async_hooks nodejs
body: <p>Why console.log which is present inside init, before, after, destroy functions in async_hooks leads to infinite maximum call stack exceed problem?</p>
  
  <p>Why does the below code goes infinite,</p>
  
  <pre><code>let asycn_hooks = require('async_hooks');
  
  async_hooks.createHook({
    init(asyncId, type, triggerAsyncId) {
      console.log(asyncId);
    },
    before(asyncId) {
      console.log(asyncId);
    },
    after(asyncId) {
      console.log(asyncId);
    },
    destroy(asyncId) {
      console.log(asyncId);
    },
  }).enable();
  setTimeout(() =&gt; {
    console.log('&gt;&gt;&gt;', async_hooks.executionAsyncId());
  }, 10);
  </code></pre>
  
  <p>but the below code doesn't</p>
  
  <pre><code>let async_hooks = require('async_hooks');
  let fs = require('fs');
  
  async_hooks.createHook({
    init(asyncId, type, triggerAsyncId) {
      fs.writeFileSync(1,`init ${asyncId} \n`);
    },
    before(asyncId) {
      fs.writeFileSync(1,`before ${asyncId} \n`);
    },
    after(asyncId) {
      fs.writeFileSync(1,`after ${asyncId} \n`);
    },
    destroy(asyncId) {
      fs.writeFileSync(1,`destroy ${asyncId} \n`);
    },
  }).enable();
  
  setTimeout(() =&gt; {
      console.log('&gt;&gt;&gt;', async_hooks.executionAsyncId());
    }, 0);
  </code></pre>