节点js-错误[ERR_IPC_CHANNEL_CLOSED]:频道已关闭

时间:2018-06-22 15:05:31

标签: node.js

使用SetImmediate()方法时发生错误。 这是错误代码。

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 <anonymous>
Emitted 'error' event at:
    at process.nextTick (internal/child_process.js:603:35)
    at process._tickCallback (internal/process/next_tick.js:112:11)

这是我的原始剧本

mine()

async function mine () {
  const newBlocks = await Bitcoin.mine(miner.pk, miner.sk)
  // console.log(newBlocks)
  if (newBlocks !== null && newBlocks.length > 0) {
    console.log(newBlocks)
    process.send({
      type: 'info',
      newBlocks: newBlocks
    })
  }
  setImmediate(mine)
}

当我不使用异步功能,但必须使用异步功能时,此方法有效。

0 个答案:

没有答案