Skip to content

Client.getContacts() returns a list of empty objects #201690

@Rakambda

Description

@Rakambda

Issue Description

Seems like #201680 broke the client.getContacts() method.
Instead of returning a list of objects, it now returns a list of promises that are not mapped onto the appropriate object.

Image

If I change locally Client.js to have

    /**
     * Get all current contact instances
     * @returns {Promise<Array<Contact>>}
     */
    async getContacts() {
        let contacts = await this.pupPage.evaluate(() => {
            const promises = window.WWebJS.getContacts();
            return Promise.allSettled(promises);
        });

return contacts
                .filter((res => res.status === 'fulfilled'))
                .map((res) => res.value)
                .map((contact) => ContactFactory.create(this, contact));
    }

then the client.getContacts() method returns contacts properly again.

Or maybe the typings didn't get changed accordingly to Promise<Array<Promise<Contact>>>.

Reproduction Steps

  1. Use the lib from the main branch
  2. Call await client.getContacts()
  3. Observe result

Code Sample

const { Client } = require('whatsapp-web.js');
const qrcode = require('qrcode-terminal');

const client = new Client();

client.on('qr', (qr) => {
    qrcode.generate(qr, { small: true });
});

client.on('ready', () => {
    console.log('Client is ready!');
    const contacts = await this.client.getContacts();
    console.log(contacts);
});

client.initialize();

User Setup

WhatsApp Type
Account Type Standard
Authentication Strategy LocalAuth
WhatsApp Web Version 2.3000.1036609119
whatsapp-web.js Version main - 1a9a1b7
Environment Version
Browser Type Google Chrome
Browser Version 146.0.7680.178
Phone OS Version ios 26.4
Running OS Version Windows 11
Node.js Version 25.9.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 mediumMedium impact issuetypingsType definitions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions