Skip to content

Fetch message againt Client is not working #201710

@MalikHamzaSaleemi

Description

@MalikHamzaSaleemi

Issue Description

Messages are not loading or displaying in the WhatsApp web chat. When trying to retrieve messages for a single chat, the messages are not being fetched or displayed, causing the chat to appear empty or unresponsive.

Environment:

whatsapp-web.js Version: "whatsapp-web.js": "github:pedroslopez/whatsapp-web.js#main"
puppeteer Version: "puppeteer": "^24.23.0"
puppeteer-core Version: "puppeteer-core": "^24.23.0"

Reproduction Steps

Initialize the whatsapp-web.js client and login successfully using QR code.
Attempt to retrieve messages from a single WhatsApp chat.
The chat opens, but no messages load or display.
Attempting to fetch messages for the chat results in no output, leaving the chat empty.

Expected Behavior:
Messages should load and display correctly for a single chat, just like it works for other chats.

Code Sample

// Replace with actual chatId
  const chatId = '123456789@c.us';
 
  const chat = await client.getChatById(chatId);
    if (!chat) throw new Error('Chat not found in WhatsApp');
      const totalToFetch = offset + limit;
      rawMessages = await chat.fetchMessages({ limit: totalToFetch });

Also tested the following

try {
    const chat = await client.getChatById(chatId);
    if (!chat) throw new Error('Chat not found.');

// Fetch messages
    const messages = await chat.fetchMessages({ limit: 100 });
    
    // Process messages
    const processedMessages = messages.map((message) => ({
      id: message.id._serialized,
      from: message.from,
      to: message.to,
      timestamp: message.timestamp,
      body: message.body || '',
      type: message.type,
      isQuoted: message.hasQuotedMsg,
      quotedMessage: message.quotedMsg ? message.quotedMsg.body : null,
    }));

console.log('Fetched Messages:', processedMessages);
  } catch (err) {
    console.error('Error fetching messages:', err.message);
  }
});

client.initialize();

User Setup

WhatsApp Type
Account Type WhatsApp Business
Authentication Strategy RemoteAuth
WhatsApp Web Version github:pedroslopez/whatsapp-web.js#main
whatsapp-web.js Version 1.34.6
Environment Version
Browser Type Chromium
Browser Version v24.23.0
Phone OS Version Andriod
Running OS Version ubuntu & Windows 11
Node.js Version v22.18.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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions