whatsapp-web.js
whatsapp-web.js copied to clipboard
Error: Evaluation failed: N and Error: Evaluation failed: d
Is there an existing issue for this?
- [x] I have searched the existing issues
Describe the bug
Uploading Videos: Error: Evaluation failed: N
Uploading Audios: Error: Evaluation failed: d
at ExecutionContext._evaluateInternal (C:\Users\xxxx\node_modules\whatsapp-web.js\node_modules\puppeteer\src\common\ExecutionContext.ts:273:13)
at runMicrotasks (
I'm trying to send media in formats: videos, audios and I face the problems described above.)
Expected behavior
Waiting for the media to be sent, but the application crashes
Steps to Reproduce the Bug or Issue
- Start a Connection
- Send a Video or Image
Relevant Code
let media = await MessageMedia.fromUrl('urlvideo', { unsafeMime: true }) await msg.reply(media)
Browser Type
Google Chrome
WhatsApp Account Type
WhatsApp Business
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
SO: Windows 11 Phone OS: Android whatsapp-web.js github branch buttons-fix WA Web Version: 2.2236.10 Node.jS Version: v16.15.0
Additional context
No response
unstale
same here
I get the same error, maybe there is a solution?
same here
unstale
Same error for me too.
unstale
unstale
unstale
@viniciusgdr I fixed the issue by checking if the message is video and then uploading it as a document.
let options: WAWebJS.MessageSendOptions = {
caption: hasBody,
sendAudioAsVoice: true
};
if (media.mimetype.includes("video")) {
options = {
caption: hasBody,
sendAudioAsVoice: true,
sendMediaAsDocument: true
};
}
const sentMessage = await wbot.sendMessage(
`${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`,
newMedia,
options
);````
yep same thing
i can only send as sendMediaDocument = true
and its look ugly
any fix to send as video ?
WhatsApp is capricious about video. Go to the official site and check whether your video is suitable or not
I solve it without looking ugly by not using pupeteer defaults : You need to set this env variable PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true And install chrome into your server/pc manually. This is my example using docker
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ENV CHROME_BIN=google-chrome-stable
Then on whatsappjs
const wbot: Session = new Client({
session: sessionCfg,
authStrategy: new LocalAuth({ clientId: `bd_${whatsapp.id}` }),
puppeteer: {
executablePath: process.env.CHROME_BIN || undefined,
browserWSEndpoint: process.env.CHROME_WS || undefined,
args: args.split(" ")
}
});
This works beacuse chrome is able to send video format as requested by whatsapp and chromium will not.
this did not work withe my project
const client = new Client({ puppeteer: { executablePath: process.env.CHROME_BIN || undefined, browserWSEndpoint: process.env.CHROME_WS || undefined, args: ["--no-sandbox"] }, authStrategy: new LocalAuth({ clientId:
bd_${undefined}`, dataPath: constants.sessionPath})
});
`
Same error for me too.
What size you media is, and what kind?
You fix this by using chrome instead of pupeteer default chromium
i am still facing this issue:
Error during sending message: Error: Evaluation failed: N 1|index | at ExecutionContext._evaluateInternal (//node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
i am still facing this issue:
Error during sending message: Error: Evaluation failed: N 1|index | at ExecutionContext._evaluateInternal (//node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
I managed to solve this, besides passing the chrome path to puppeter:
new Client({
authStrategy: new LocalAuth(),
webVersionCache: {
type: "remote",
remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2332.15.html',
},
puppeteer: {
executablePath: '/usr/bin/google-chrome-stable',
args: ['--no-sandbox', '--disable-setuid-sandbox'],
headless: true
}
})
But also converting the video to mp4 with ffmpeg (Sometimes even though the video was already in .mp4 it gave the error, so when using ffmpeg it works):
const { exec } = require("child_process")
exec(`ffmpeg -i ${filePath} -preset superfast -crf 30 -c:v libx264 ${newPath}`, (err, stdout, stderr) => {
if(err){
console.log(`convert video error: ${err}`)
return resolve(null)
}else{
console.log(`convert video success`)
return resolve(newPath)
}
})
And then I send the video like this:
message.reply(MessageMedia.fromFilePath(newPath))
I am already using that :
const store = new MongoStore({ mongoose: mongoose });
let browser_path = '/usr/bin/google-chrome-stable'; // for Linux
if (process.env.NODE_ENV !== 'production') {
browser_path = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'; // for Mac OS
}
const client = new Client({
authStrategy: new LocalAuth({
store: store,
backupSyncIntervalMs: 300000
}),
puppeteer: {
executablePath: browser_path,
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-extensions']
},
restartOnAuthFail: true
});
I'm encountering an issue while attempting to send a video file using whatsapp-web.js with a CDN URL such as []("https://download.ig-10-data.xyz/ig/1709204866/a5e9ee198d0c2b9f241f65c88ccb596be76a6e120e31114e5a354773a75a77b7?file=aHR0cHM6Ly9zY29udGVudC5jZG5pbnN0YWdyYW0uY29tL3YvdDY2LjMwMTAwLTE2LzEwMDAwMDAwXzkyNTQxNjA1NTgxNjA2N18zNzE0MjE2ODYxOTEyNzc1NTE0X24ubXA0P19uY19odD1zY29udGVudC1mcmEzLTIuY2RuaW5zdGFncmFtLmNvbSZfbmNfY2F0PTExMSZfbmNfb2hjPTdja3FnQ0hQX29nQVgtUVcwSHkmZWRtPUFQX1YxMEVCQUFBQSZjY2I9Ny01Jm9oPTAwX0FmQzNKbzduZ3ItN1ZwQmdQazU4LVJEQ28zTU9WQndIRTRLZFg3SlBOdWlkZ1Emb2U9NjVFMjBEOTYmX25jX3NpZD0yOTk5YjgmbmFtZT1TYXZlSUcuQXBwXzMyNzg1ODkzMDAyNDAwNTUwMTIubXA0". When using this URL, I receive an error message: "Error during sending video: Error: Evaluation failed: N".)
Additional Context:
The issue does not occur when sending small video files using other URLs, such as "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4". I have attempted various approaches to resolve the issue, including using buffer-based methods as mentioned in the whatsapp-web.js documentation, but the problem persists specifically with CDN URLs. Any insights or suggestions on how to resolve this issue would be greatly appreciated. Thank you!
@pedroslopez @PurpShell please help
Just send the video in .mov format
const media = new MessageMedia('video/mov', b64data, title);