fent / node-ytdl-core

YouTube video downloader in javascript.
MIT License
4.48k stars 793 forks source link

UnhandledPromiseRejectionWarning: evalmachine.<anonymous>:24 #1120

Closed neburmine closed 2 years ago

neburmine commented 2 years ago

Problem occours in old an new version of ytdl-core , problem came up out of no where without updating and did not get resolved by updating.

Im running a discord bot that uses the ytdl-core to get the info from a url, and stream it to a user channel, it has been running without problem for the last 6 months and stopped 2 days ago. Now everytime the code gets to ytdl.GetInfo(videourl) it crashes with the following error code:


(node:258772) UnhandledPromiseRejectionWarning: evalmachine.<anonymous>:24
c[72],c[6]),(0,c[85])(c[11]),(0,c[41])(c[39],c[28],(0,c[66])()),(0,c[78])(c[Math.pow(6,2)+122+-119],c[new Date("Wednesday December 31 1969 19:00:14 CDT")/1E3])}catch(d){(0<c[0]||(((0,c[80])(c[60],c[88]),c[80])(c[21],c[88]),0))&&(0,c[17])((0,c[70])(c[6]),c[78],c[88],c[12])}try{2<c[91]&&(1<c[53]?(0,c[17])((0,c[80])(c[82],c[6]),c[78],c[39],c[5]):((0,c[45])(c[49],c[88]),c[78])(c[88],c[86])),(0,c[17])((0,c[85])(c[31]),c[41],c[88],c[75],(0,c[35])())}catch(d){}};Wka(ncode);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ^

SyntaxError: Missing catch or finally after try
    at new Script (vm.js:88:7)
    at Object.exports.decipherFormats (/home/neburmine/GamingServerServices/discord_bot/node_modules/ytdl-core/lib/sig.js:116:51)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
    at async exports.getInfo (/home/neburmine/GamingServerServices/discord_bot/node_modules/ytdl-core/lib/info.js:401:17)
(node:258772) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:258772) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I look around on the internet for a similar issue but cant find anything alike. The error seems to occour in the next bit of code, ytdl core executes ytdl.validateURL() fine without error but crashes when trying to use ytdl.getInfo(). The error also doesnt seem to point to a part in my code so that is why i'm asking for help here.


if (!args.length) return message.channel.send('You need to send the second argument!');
            let song = {};
            console.log(await spotifyToYT.validateURL(args[0]))
            //If the first argument is a link. Set the song object to have two keys. Title and URl.
            if (await ytdl.validateURL(args[0])) {
                const song_info = await ytdl.getInfo(args[0]);
                song = { title: song_info.videoDetails.title, url: song_info.videoDetails.video_url, secLenght: song_info.videoDetails.lengthSeconds, live: song_info.videoDetails.isLiveContent}
                addedsong = await queue_constructor_fuction(server_queue ,message, song, voice_channel)
                message.channel.send(` **${song.title}** added to queue!`);
neburmine commented 2 years ago

just saw its a duplicate of #1113 sorry