getting-started icon indicating copy to clipboard operation
getting-started copied to clipboard

This hot-reload example will not work on the second bot if it is launched asynchronically

Open demobo-com opened this issue 6 years ago • 1 comments

const { Wechaty } = require('wechaty')

function setupBot(id) {
  const bot = new Wechaty({ profile: `memory-cards/${id}` })
  bot
    .on('scan', './on-scan')
    .start()
  return bot
}

setInterval(async () => {
  setupBot(Math.random())
}, 10000)

We are working on launching bot dynamically. However, whenever we are using hot-reload, any bot launched after the first one will fail. This example will work if we are not using hot-reload.

Error: ERR Wechaty onModulePath(scan, ./on-scan) listener exception: TypeError: Cannot read property 'apply' of undefined

demobo-com avatar Jan 03 '19 00:01 demobo-com

Thanks for point out this with code.

I'll look into it when I get time.

huan avatar Jan 03 '19 04:01 huan