title: Node js - Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
body: <p>Error occur when using <code>SetImmediate()</code> method.
  This is error code.</p>
  
  <pre><code>Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
  at process.target.send (internal/child_process.js:599:16)
  at Immediate.mine (/Volumes/Work/ProjectsByClient/ULC/Exerices/ex6/coinGenerator.js:30:13)
  at &lt;anonymous&gt;
  Emitted 'error' event at:
      at process.nextTick (internal/child_process.js:603:35)
      at process._tickCallback (internal/process/next_tick.js:112:11)
  </code></pre>
  
  <p>This is my original script</p>
  
  <pre><code>mine()
  
  async function mine () {
    const newBlocks = await Bitcoin.mine(miner.pk, miner.sk)
    // console.log(newBlocks)
    if (newBlocks !== null &amp;&amp; newBlocks.length &gt; 0) {
      console.log(newBlocks)
      process.send({
        type: 'info',
        newBlocks: newBlocks
      })
    }
    setImmediate(mine)
  }
  </code></pre>
  
  <p>This was worked when I didn't use async function, but I must use async function.</p>