Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
demobo-com opened this issue Jan 3, 2019 · 1 comment

Comments

@demobo-com
Copy link

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

@huan
Copy link
Member

huan commented Jan 3, 2019

Thanks for point out this with code.

I'll look into it when I get time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants