Skip to content

sendMessage returns undefined #201857

Description

@iqrojp

Issue Description

Client.sendMessage works, message sent but the function returns undefined

i even tested it with minimal code on fresh new node project

other thing i recall is i recently try to delete C:\Users\User\.cache while the whatsapp client is running, and i get a warning from windows that files inside it is in use, turns out it contains the chrome used by puppeteer.
but i stopped the whatsapp client, deleted the .cache folder and reinstalled it, but i dont know if thats the cause.

Reproduction Steps

  1. call await Client.sendMessage()
  2. log the value returned by sendMessage
  3. it should be undefined

Code Sample

// minimal code tested on new project
...
import pkg from 'whatsapp-web.js';
const { Client, LocalAuth, MessageMedia, Buttons } = pkg;

...

// --- WA Client ---
const waClient = new Client({
  puppeteer: {
    args: ['--no-sandbox', '--disable-setuid-sandbox']
  },
  authStrategy: new LocalAuth({ dataPath: path.join(DATA_DIR, "sessions") }),
});

...

waClient.on('ready', async () => {
  console.log('WA client is READY');
  const sent = await waClient.sendMessage("*************@c.us", "Client ready"); // <--- here, 'sent' is undefined
  console.log('client ready message:', sent);
});

waClient.on("message_create", async (msg) => {
    console.log('Received', msg);
});

waClient.initialize();

User Setup

WhatsApp Type
Account Type Standard
Authentication Strategy LocalAuth
WhatsApp Web Version 2.3000.1043612726
whatsapp-web.js Version 1.34.7
Environment Version
Browser Type chrome
Browser Version win64-146.0.7680.31
Phone OS Version android 10
Running OS Version Windows 10
Node.js Version 22.19.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