Issue Priority
High (immediate attention needed)
Issue Description
Message.downloadMedia() throws an opaque r: r error for every incoming media message. This reproduces with directly sent and forwarded images and PDF documents.
The client remains connected and receives text messages normally. The failure is isolated to media download. Without a try/catch around msg.downloadMedia(), the rejected promise reaches triggerUncaughtException and terminates the Node.js process. Catching it prevents the crash but leaves the message without media data.
Observed stack:
node:internal/process/promises:391
triggerUncaughtException(err, true /* fromPromise */);
^
r: r
at #evaluate (.../puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:391:56)
at async ExecutionContext.evaluate (.../ExecutionContext.js:277:16)
at async IsolatedWorld.evaluate (.../IsolatedWorld.js:100:16)
at async CdpFrame.evaluate (.../api/Frame.js:362:20)
at async CdpPage.evaluate (.../api/Page.js:830:20)
at async Message.downloadMedia (.../whatsapp-web.js/src/structures/Message.js:518:24)
This started suddenly after working earlier on the same day, with no application or dependency update. The same application code and lockfile had previously downloaded forwarded media successfully.
I also tested a strict archived WhatsApp Web snapshot to rule out a local-cache fallback:
- Live version observed:
2.3000.1043163628
- Strict remote snapshot:
2.3000.1043159177-alpha
webVersionCache: remote with strict: true
The client connected successfully with the archived snapshot, but downloadMedia() failed in the same way. Recreating the Docker containers, deleting the LocalAuth session, scanning a new QR code, and testing direct/forwarded image/PDF messages did not change the result.
Steps To Reproduce
- Initialize a client using
LocalAuth and Chromium.
- Wait for the
ready event.
- Send an image or PDF to the connected account, either directly or by forwarding it.
- In the
message handler, check msg.hasMedia and call await msg.downloadMedia().
- Observe Puppeteer's
ExecutionContext.evaluate reject with the opaque error r: r.
- If the call is not caught, Node.js terminates through
triggerUncaughtException.
Code Sample
const { Client, LocalAuth } = require('whatsapp-web.js');
const client = new Client({
authStrategy: new LocalAuth({ dataPath: './session' }),
puppeteer: {
headless: true,
executablePath: '/usr/bin/chromium-browser',
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'],
},
});
client.on('message', async (msg) => {
if (!msg.hasMedia) return;
const media = await msg.downloadMedia();
console.log(media?.mimetype, media?.data?.length);
});
client.initialize();
Environment
- WhatsApp Account Type: unavailable at report time
- Authentication Strategy: LocalAuth
- whatsapp-web.js Version:
1.34.7
- WhatsApp Web Version:
2.3000.1043163628; also reproduced with strict archived 2.3000.1043159177-alpha
- Browser Type: Chromium
- Browser Version:
149.0.7827.53
- Computer OS Version: Alpine Linux
3.23.4, Docker Linux ARM64
- Phone OS Version: unavailable at report time
- Node.js Version:
20.20.2
Checklist
Issue Priority
High (immediate attention needed)
Issue Description
Message.downloadMedia()throws an opaquer: rerror for every incoming media message. This reproduces with directly sent and forwarded images and PDF documents.The client remains connected and receives text messages normally. The failure is isolated to media download. Without a
try/catcharoundmsg.downloadMedia(), the rejected promise reachestriggerUncaughtExceptionand terminates the Node.js process. Catching it prevents the crash but leaves the message without media data.Observed stack:
This started suddenly after working earlier on the same day, with no application or dependency update. The same application code and lockfile had previously downloaded forwarded media successfully.
I also tested a strict archived WhatsApp Web snapshot to rule out a local-cache fallback:
2.3000.10431636282.3000.1043159177-alphawebVersionCache: remote withstrict: trueThe client connected successfully with the archived snapshot, but
downloadMedia()failed in the same way. Recreating the Docker containers, deleting the LocalAuth session, scanning a new QR code, and testing direct/forwarded image/PDF messages did not change the result.Steps To Reproduce
LocalAuthand Chromium.readyevent.messagehandler, checkmsg.hasMediaand callawait msg.downloadMedia().ExecutionContext.evaluatereject with the opaque errorr: r.triggerUncaughtException.Code Sample
Environment
1.34.72.3000.1043163628; also reproduced with strict archived2.3000.1043159177-alpha149.0.7827.533.23.4, Docker Linux ARM6420.20.2Checklist
downloadMedia,downloadAndMaybeDecrypt, media download, and the opaquererror and found no clear duplicate.Message.downloadMedia()/ Puppeteer page evaluation, not in downstream application handling.