From fd368361df9627d48d3046fd712c7f6330d53476 Mon Sep 17 00:00:00 2001 From: Jeremy Andes <73316325+jeremyandes@users.noreply.github.com> Date: Tue, 9 Aug 2022 12:30:56 -0300 Subject: [PATCH] Fix: Cannot read properties of undefined (reading 'id') (#1604) This change fix `react` evaluation: ``` Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'id') at Object. (https://web.whatsapp.com/bootstrap_main.44dc3fdf06d9bb8b053d.js:2:103021) at Generator.next () at t (https://web.whatsapp.com/vendor1~bootstrap_qr.5922e52928d864c0918c.js:2:66483) at s (https://web.whatsapp.com/vendor1~bootstrap_qr.5922e52928d864c0918c.js:2:66694) at https://web.whatsapp.com/vendor1~bootstrap_qr.5922e52928d864c0918c.js:2:66753 at Y (https://web.whatsapp.com/bootstrap_qr.f74b98c729dd38392a5f.js:37:128505) at new y (https://web.whatsapp.com/bootstrap_qr.f74b98c729dd38392a5f.js:37:121072) at Object. (https://web.whatsapp.com/vendor1~bootstrap_qr.5922e52928d864c0918c.js:2:66634) at Object.k (https://web.whatsapp.com/bootstrap_main.44dc3fdf06d9bb8b053d.js:2:105511) at Object.t.sendReactionToMsg (https://web.whatsapp.com/bootstrap_main.44dc3fdf06d9bb8b053d.js:2:102647) at ExecutionContext._evaluateInternal (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ExecutionContext.evaluate (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16) at async Message.react (/app/node_modules/whatsapp-web.js/src/structures/Message.js:344:9) ``` Co-authored-by: Rajeh Taher --- src/structures/Message.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/structures/Message.js b/src/structures/Message.js index 899241b..7c1d3d0 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -342,6 +342,8 @@ class Message extends Base { */ async react(reaction){ await this.client.pupPage.evaluate(async (messageId, reaction) => { + if (!messageId) { return undefined; } + const msg = await window.Store.Msg.get(messageId); await window.Store.sendReactionToMsg(msg, reaction); }, this.id._serialized, reaction);