-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Is there an existing issue for this?
- I have searched the existing issues.
Is this a problem caused by your code, or is it specifically because of the library?
- I have double-checked my code carefully.
Describe the bug.
Hello, I'm using the 1.34.2 version of the library and up to now everithing is going (almost) ok. This morning, when the script tries to download a media content (video/audio/image), the following error occurs:
Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'addAnnotations')
at https://static.whatsapp.net/rsrc.php/v4iyjK4/y-/l/en_US-j/3CDGXrT_r_i.js:1139:1963
at Generator.next (<anonymous>)
at l (https://static.whatsapp.net/rsrc.php/v4/y9/r/oVOFaRVi60d.js:107:125)
at i (https://static.whatsapp.net/rsrc.php/v4/y9/r/oVOFaRVi60d.js:107:349)
at https://static.whatsapp.net/rsrc.php/v4/y9/r/oVOFaRVi60d.js:107:408
at new Promise (<anonymous>)
at https://static.whatsapp.net/rsrc.php/v4/y9/r/oVOFaRVi60d.js:107:277
at https://static.whatsapp.net/rsrc.php/v4iyjK4/y-/l/en_US-j/3CDGXrT_r_i.js:1139:2970
The code in my script is the same of yesterday (I wrote it about an year ago) and all other conditions are the same.
Can someone help me, please?
Expected Behavior
Download the media file without errors
Steps to Reproduce the Bug or Issue
if (msg.hasMedia) {
//console.log('******** DEBUG 1 ************');
try {
if (debug) {
console.log('Sto scaricando un allegato del numero: ' + numero);
}
media = await msg.downloadMedia();
} catch (err) {
console.log('Errore download allegato dal numero: ' + numero + ' --> ' + err);
require("fs").writeFile(process.cwd() + '/log/log.txt', 'Errore download messaggio ' + numero + ' --> ' + err + '\n', {
flag: 'a+'
}, err => {});
}
if (media != undefined) {
//console.log('******** DEBUG 2 ************');
console.log("Media mimetype: "+media.mimetype);
nomeFile = media_temp_dir + numero + '_' + msg.timestamp;
var extension = ''
if (media.mimetype == 'image/jpeg') {
nomeFile = nomeFile + '.jpg';
tipoMessaggio = 'image';
extension = 'jpg';
} else if (media.mimetype == 'image/png') {
nomeFile = nomeFile + '.png';
tipoMessaggio = 'image';
extension = 'png';
} else if (media.mimetype == 'image/gif') {
nomeFile = nomeFile + '.gif';
tipoMessaggio = 'image';
extension = 'gif';
} else if (media.mimetype == 'image/webp') {
nomeFile = nomeFile + '.webp';
tipoMessaggio = 'image';
extension = 'webp';
} else if (media.mimetype == 'video/mp4') {
nomeFile = nomeFile + '.mp4';
tipoMessaggio = 'video';
extension = 'mp4';
} else if (media.mimetype == 'audio/ogg; codecs=opus') {
nomeFile = nomeFile + '.ogg';
tipoMessaggio = 'audio';
extension = 'ogg';
}
try {
var base64Data = media.data;
require("fs").writeFile(nomeFile, base64Data, 'base64', function(err) {
if ((err != undefined) && (err != null)) {
console.log("Errore salvataggio allegato del numero: " + numero + " --> " + err);
require("fs").writeFile(process.cwd() + '/log/log.txt', 'Errore salvataggio allegato ' + numero + ' --> ' + err + '\n', {
flag: 'a+'
}, err => {});
}
if (debug)
console.log('Salvataggio allegato ' + nomeFile + ' del numero: ' + numero);
sender.set_media(tipoMessaggio, nomeFile, extension);
lastHandledTimestamp = now;
sender.send();
});
} catch (err) {
console.log('Errore scrittura file in B64 --> ' + err);
require("fs").writeFile(process.cwd() + '/log/log.txt', 'Errore scrittura file in B64 ' + numero + ' --> ' + err + '\n', {
flag: 'a+'
}, err => {});
}
}
WhatsApp Account Type
Standard
Browser Type
Chromium
Operation System Type
Ubuntu 20.04
Phone OS Type
Android
WhatsApp-Web.js Version
1.34.2
WhatsApp Web Version
2.3000.1030934145
Node.js Version
20.14.0
Authentication Strategy
NoAuth
Additional Context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working