wechaty / puppet-wechat

Wechaty Puppet Provider for WeChat
https://www.npmjs.com/package/wechaty-puppet-wechat
Apache License 2.0
408 stars 68 forks source link

Nudge (拍一拍) Message Cause Error #122

Open zzc-tongji opened 4 years ago

zzc-tongji commented 4 years ago

Description

When anyone nudges (拍一拍) anyone in a group, an error will be thrown (even not terminate the process).

Environments

Log

(node:2596) UnhandledPromiseRejectionWarning: Error: not found
    at PuppetPuppeteer.<anonymous> ([project-path]\node_modules\wechaty\node_modules\wechaty-puppet-puppeteer\src\puppet-puppeteer.ts:998:13)
    at Generator.next (<anonymous>)
    at fulfilled ([project-path]\node_modules\wechaty\node_modules\wechaty-puppet-puppeteer\dist\src\puppet-puppeteer.js:23:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2596) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2596) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, 
promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
zzc-tongji commented 4 years ago

I have located the bug.

bot.on('message', (m) => {
  const one = m.from();
  const room = m.room();
  if (room) {
    room.alias(one).then((data) => {
      // get sender's alias in room
    }).catch((error) => {
      // nudge (拍一拍) message causes error
    })
  }
});
huan commented 4 years ago

Good catch, and thank you very much for pointing out where the problem is!

A PR for fixing this issue is welcome.