From 3db846ed08a3c74657600028b1c4f50c1fd10b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20LI=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Sun, 3 May 2020 16:28:18 +0800 Subject: [PATCH] check return promise from plugin --- src/wechaty.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wechaty.ts b/src/wechaty.ts index c93b545c..19e2df1e 100644 --- a/src/wechaty.ts +++ b/src/wechaty.ts @@ -570,7 +570,10 @@ export class Wechaty extends EventEmitter implements Sayable { for (const plugin of plugins) { try { const future = plugin(this) - if (future) { + /** + * We check `future.catch` at here is to prevent some plugin that return something other than `void`(undefined) + */ + if (future && typeof future.catch === 'function') { future.catch(e => { log.error('Wechaty', 'use(%s) rejection: %s', plugin.name, -- GitLab