Skip to content

fetchMessages Not Working #201719

Description

@tawityagi

Issue Description

Facing issue when calling fetchMessages

Error [TypeError]: Cannot read properties of undefined (reading 'waitForChatLoading')
Object. (https://static.whatsapp.net/rsrc.php/v4iu4R4/yX/l/en_GB-j/Ynaf25JJq1v.js:2085:1607)
Generator.next ()
at evaluate (evaluate at PrivateChat.fetchMessages (/app/node_modules/whatsapp-web.js/src/structures/Chat.js:193:50), :16:79)
at #evaluate (/app/node_modules/whatsapp-web.js/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:391:56)
at async ExecutionContext.evaluate (/app/node_modules/whatsapp-web.js/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:277:16)
at async IsolatedWorld.evaluate (/app/node_modules/whatsapp-web.js/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:100:16)
at async CdpFrame.evaluate (/app/node_modules/whatsapp-web.js/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:362:20)
at async CdpPage.evaluate (/app/node_modules/whatsapp-web.js/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:818:20)
at async PrivateChat.fetchMessages (/app/node_modules/whatsapp-web.js/src/structures/Chat.js:193:24)
at async /app/server.js:472:35
at y (https://static.whatsapp.net/rsrc.php/v4iu4R4/yX/l/en_GB-j/Ynaf25JJq1v.js:2084:1394)
at (https://static.whatsapp.net/rsrc.php/v4/y8/r/cqQl5CN3vO-.js:108:276)
at (https://static.whatsapp.net/rsrc.php/v4/y8/r/cqQl5CN3vO-.js:108:407)
at i (https://static.whatsapp.net/rsrc.php/v4/y8/r/cqQl5CN3vO-.js:108:348)
at l (https://static.whatsapp.net/rsrc.php/v4/y8/r/cqQl5CN3vO-.js:108:124)
at (https://static.whatsapp.net/rsrc.php/v4iu4R4/yX/l/en_GB-j/Ynaf25JJq1v.js:2084:1606)

Reproduction Steps

  1. Scan QR
  2. After successful scan, fetch chatIds via getChats()
  3. For given chatid,
    const chat = await client.getChatById(chatId);
    await chat.sendSeen(); // working fine till here
    const msgs = await chat.fetchMessages({ limit: 50 });

Code Sample

User Setup

WhatsApp Type
Account Type Standard
Authentication Strategy LocalAuth
WhatsApp Web Version 2.2412.54
whatsapp-web.js Version 1.34.6
Environment Version
Browser Type Chromium
Browser Version Headless
Phone OS Version Android
Running OS Version Windows
Node.js Version 18.0.0

Checklist

  • I use the latest released version of whatsapp-web.js.
  • I have searched existing issues and confirmed this is not a duplicate.
  • I have verified this is a library issue, not a problem with my code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is brokenissued highHigh impact issuetypingsType definitions

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions