pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.53k stars 3.7k forks source link

triggerUncaughtException(err, true /* fromPromise */); #2528

Closed twixt1 closed 11 months ago

twixt1 commented 1 year ago

Is there an existing issue for this?

Describe the bug

When i try to send videos that downloaded by ytdl-core it shown this error only for some videos but for some videos it downloads and send perfectly

Expected behavior

node:internal/process/promises:288 triggerUncaughtException(err, true / fromPromise /); ^

u: u at #evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:229:55) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async ExecutionContext.evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:126:16) at async IsolatedWorld.evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\IsolatedWorld.js:128:16) at async CdpFrame.evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Frame.js:370:20) at async CdpPage.evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Page.js:886:16) at async Client.sendMessage (C:\Users\AH\Desktop\zyntex bot\node_modules\@juzi\whatsapp-web.js\src\Client.js:903:28)

Node.js v18.14.1

Steps to Reproduce the Bug or Issue

It occures when trying to send videos that downloaded for ytdl-core(only for some videos)

Relevant Code

client.on('message', async (message) => { if (message.body.startsWith('.yt')){

  const url = message.body.slice(3).trim()

  try{

    ytdl.getInfo(url).then((res) => {
      const videoTitle = res.videoDetails.title

      message.reply('_*Downloading...*_\n' + '_' + videoTitle + '_')

      const videoStream = ytdl(url, { quality: 'lowest' })
      const videoFileName = 'Zynt3x.mp4'
      videoStream.pipe(fs.createWriteStream(videoFileName))

      videoStream.on('end', () => {
        async function yt(){

          const chat = await message.getChat()
          const media = await MessageMedia.fromFilePath(videoFileName ) 

          chat.sendMessage(media, {caption: videoTitle}).then(() =>{
            fs.unlinkSync(videoFileName)
          })

        }yt()
      })
    })

  }catch(err){
    message.reply('*An Error Occured!*\n' + `_*${err}*_`)
  }
}

})

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Windows 10 Phone OS: Android

Im Using tecsom-whatsapp-web.js , because whatsapp-web.js is getting error

whatsapp version: latest

node js : v18.14.1.

Additional context

No response

wilsinho8 commented 1 year ago

https://github.com/pedroslopez/whatsapp-web.js/issues/2510

Same issue, please pay attention before post a new case. Do a search to see if there is already a case about your problem

twixt1 commented 1 year ago

bro it fixed! for me i changed const videoStream = ytdl(url, { quality: 'lowest' }) to const videoStream = ytdl(url, { quality: '18' })

rikkoder commented 10 months ago

Is there an existing issue for this?

* [x]  I have searched the existing issues

Describe the bug

When i try to send videos that downloaded by ytdl-core it shown this error only for some videos but for some videos it downloads and send perfectly

Expected behavior

node:internal/process/promises:288 triggerUncaughtException(err, true / fromPromise /); ^

u: u at #evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:229:55) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async ExecutionContext.evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:126:16) at async IsolatedWorld.evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\IsolatedWorld.js:128:16) at async CdpFrame.evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Frame.js:370:20) at async CdpPage.evaluate (C:\Users\AH\Desktop\zyntex bot\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Page.js:886:16) at async Client.sendMessage (C:\Users\AH\Desktop\zyntex bot\node_modules@juzi\whatsapp-web.js\src\Client.js:903:28)

Node.js v18.14.1

Steps to Reproduce the Bug or Issue

It occures when trying to send videos that downloaded for ytdl-core(only for some videos)

Relevant Code

client.on('message', async (message) => { if (message.body.startsWith('.yt')){

  const url = message.body.slice(3).trim()

  try{

    ytdl.getInfo(url).then((res) => {
      const videoTitle = res.videoDetails.title

      message.reply('_*Downloading...*_\n' + '_' + videoTitle + '_')

      const videoStream = ytdl(url, { quality: 'lowest' })
      const videoFileName = 'Zynt3x.mp4'
      videoStream.pipe(fs.createWriteStream(videoFileName))

      videoStream.on('end', () => {
        async function yt(){

          const chat = await message.getChat()
          const media = await MessageMedia.fromFilePath(videoFileName ) 

          chat.sendMessage(media, {caption: videoTitle}).then(() =>{
            fs.unlinkSync(videoFileName)
          })

        }yt()
      })
    })

  }catch(err){
    message.reply('*An Error Occured!*\n' + `_*${err}*_`)
  }
}

})

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Windows 10 Phone OS: Android

Im Using tecsom-whatsapp-web.js , because whatsapp-web.js is getting error

whatsapp version: latest

node js : v18.14.1.

Additional context

No response

i was using fluent-ffmpeg to download audio from stream obtained from ytdl-core, and i was having same problem while uploading the file with sendMessage. i changed the format using toFormat method of fluent-ffmpeg to the 'ipod' format and it worked.

mehrdad-kj commented 10 months ago

it is possible that somewhere in your os have a postCSS.config or tailwindCss.config that cause this error