Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Missing catch or finally after try #1246

Open
w4lx opened this issue Jul 30, 2023 · 4 comments
Open

SyntaxError: Missing catch or finally after try #1246

w4lx opened this issue Jul 30, 2023 · 4 comments

Comments

@w4lx
Copy link

w4lx commented Jul 30, 2023

Error caused when you search for a specific video (this rarely happens) but it also usually occurs when you request the same video many times.

@Kinuseka
Copy link

hello I can +1 for this issue happens to my application as well

to add up I can provide logs:

evalmachine.<anonymous>:23
-198148851,1640174308];c[24]=c;c[48]=c;c[52]=c;try{try{-7>=c[44]&&((0,c[42])((0,c[78])(c[52],c[28]),c[70],(0,c[13])(c[83]),c[55],c[52]),c[27])((0,c[31])(c[83],c[69]),c[65],c[17],c[24]),((0,c[30])(),c[37])(c[68],c[new Date("1970-01-01T08:00:04.000+08:00")/1E3])};hma(ncode);
                                                                                                                                                                                                                                                                    ^

SyntaxError: Missing catch or finally after try
    at new Script (node:vm:94:7)
    at exports.decipherFormats (/home/nine/kinuska/node_modules/ytdl-core/lib/sig.js:116:51)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async exports.getInfo (/home/nine/kinuska/node_modules/ytdl-core/lib/info.js:401:17)

The root cause was unknown but I remembered updating my packages before this issue happened (perhaps a typo pushed to release?)

@Kinuseka
Copy link

some more debug by capturing the functions variable using console
https://github.com/fent/node-ytdl-core/blob/9e15c7381f1eba188aba8b536097264db6ad3f7e/lib/sig.js#L114C2-L116C86

successful:

  'var oI={vQ:function(a,b){a.splice(0,b)},\n' +
    'k4:function(a){a.reverse()},\n' +
    'yV:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c}};var Usa=function(a){a=a.split("");oI.yV(a,3);oI.k4(a,15);oI.yV(a,23);oI.yV(a,12);oI.vQ(a,3);oI.yV(a,36);oI.vQ(a,2);return a.join("")};Usa(sig);',
  'var gma=function(a){var b=a.split(""),c=[903194415,function(d,e){if(0!=d.length){e=(e%d.length+d.length)%d.length;var f=d[0];d[0]=d[e];d[e]=f}},\n' +
    '-279859854,-1469375506,1933127910,249130854,890045879,function(d,e){e=(e%d.length+d.length)%d.length;d.splice(e,1)},\n' +
    '1756236289,function(d,e,f){var h=e.length;d.forEach(function(l,m,n){this.push(n[m]=e[(e.indexOf(l)-e.indexOf(this[m])+m+h--)%e.length])},f.split(""))},\n' +
    '-1949303870,null,-764355842,b,function(d,e){d=(d%e.length+e.length)%e.length;e.splice(-d).reverse().forEach(function(f){e.unshift(f)})},\n' +
    'function(d,e){0!=d.length&&(e=(e%d.length+d.length)%d.length,d.splice(0,1,d.splice(e,1,d[0])[0]))},\n' +
    '-1747270089,-514198066,b,-1319989107,");)\\u22f6",-399135322,-1888397177,-1583074420,-1922105064,-1176780118,1382187785,-849672989,-364907785,1756236289,211439937,-399135322,function(d,e,f,h,l){return e(f,h,l)},\n' +
    '1052840190,function(d){d.reverse()},\n' +
    'function(){for(var d=64,e=[];++d-e.length-32;)switch(d){case 58:d=96;continue;case 91:d=44;break;case 65:d=47;continue;case 46:d=153;case 123:d-=58;default:e.push(String.fromCharCode(d))}return e},\n' +
    'null,-1258348009,b,860174732,-491789757,895663564,-1479853521,function(){for(var d=64,e=[];++d-e.length-32;){switch(d){case 58:d-=14;case 91:case 92:case 93:continue;case 123:d=47;case 94:case 95:case 96:continue;case 46:d=95}e.push(String.fromCharCode(d))}return e},\n' +
    '549852575,function(d,e){if(0!=d.length){e=(e%d.length+d.length)%d.length;var f=d[0];d[0]=d[e];d[e]=f}},\n' +
    '"TONX-",/}(),,({(\\/,){)}(),/,function(){for(var d=64,e=[];++d-e.length-32;){switch(d){case 91:d=44;continue;case 123:d=65;break;case 65:d-=18;continue;case 58:d=96;continue;case 46:d=95}e.push(String.fromCharCode(d))}return e},\n' +
    '-688615821,function(d){for(var e=d.length;e;)d.push(d.splice(--e,1)[0])},\n' +
    'function(d,e,f,h,l,m){return e(h,l,m)},\n' +
    '-1466408384,-1100628975,-1942434456,function(d,e){e.push(d)},\n' +
    `-270905556,1562042171,null,2099390477,1034073749,',\\\\",',88701661,-1818850199,function(d,e,f,h,l,m,n){return d(l,m,n)},\n` +
    '-826555815,-49905184,1608700174,function(d,e,f,h,l,m,n,p){return e(f,h,l,m,n,p)},\n' +
    '-1601652741,92156442,-1207321569,903194415,-878017111,function(d,e){d.splice(d.length,0,e)},\n' +
    '1440333162,function(){for(var d=64,e=[];++d-e.length-32;)switch(d){case 46:d=95;default:e.push(String.fromCharCode(d));case 94:case 95:case 96:break;case 123:d-=76;case 92:case 93:continue;case 58:d=44;case 91:}return e},\n' +
    '-107420060,-1507982315,-1212999017,function(d,e){for(d=(d%e.length+e.length)%e.length;d--;)e.unshift(e.pop())},\n' +
    '1454567656];c[11]=c;c[36]=c;c[58]=c;try{try{(2!=c[59]||((0,c[1])(c[36],c[69]),0))&&(0,c[14])(c[19],c[18]),-3>c[6]&&((0,c[1])(c[58],c[33]),"null")||(0,c[80])(c[4],c[13])}catch(d){(0,c[32])((0,c[9])(c[13],(0,c[35])(),c[46]),c[34],c[36])}finally{-2==c[72]&&((0,c[80])(c[5],c[13]),(0,c[34])(c[new Date("1970-01-01T04:15:18.000+04:15")/1E3]),(0,c[32])((0,c[32])((0,c[9])(c[38],(0,c[35])(),c[46]),c[7],c[13],c[56]),c[9],c[13],(0,c[76])(),c[46]),1)||(((0,c[51])((0,c[15])(c[18],c[54]),c[7],(0,c[15])(c[97-86%\n' +
    'Math.pow(8,4)],c[17]),c[18],c[30]),c[15])(c[13],c[75]),c[7])(c[18],c[70]),-4!==c[33]&&(0,c[14])(c[37],c[58]),8!=c[51]&&(-7>c[44]?(0,c[61])(c[75],c[58]):(0,c[61])(c[70],(0,c[18])(),c[16])),0<c[54]?(0,c[2])((0,c[15])(c[6],c[55]),c[67],c[65],c[36]):(0,c[15])(c[70],c[23])-(0,c[59])(c[70],c[27])}try{c[71]!=Math.pow(6,1)- -8710-8722&&((0,c[50])(c[79],c[8]),c[50])(c[10],c[8])}catch(d){(0,c[61])(c[8],(0,c[5])(),c[16])}finally{-3<=c[9]&&(7!=c[73]&&((0,c[2])(((0,c[67])(c[65],c[64]),(0,c[66])(c[30],c[70])),\n' +
    'c[44],c[63],c[52-Math.pow(8,3)- -526]),1)||((0,c[66])(c[22],c[70]),c[2])((0,c[59])(c[8],c[75]),c[61],c[65],(0,c[13])(),c[16])),(-7<c[79]||((((0,c[2])(((0,c[66])(c[76],c[65]),c[4])(c[70]),c[50],c[19],c[new Date("1970-01-01T09:48:56.000+09:45")/1E3*Math.pow(3,2)-2118]),c[48])(c[57],(0,c[0])(),c[3]),c[31])(c[15],c[32]),0))&&(((0,c[48])(c[78],(0,c[5])(),c[3]),c[8])((0,c[40])(c[50],c[30]),c[46],(0,c[74])(c[78]),c[78],c[1]),c[48])(c[57],(0,c[5])(),c[3]),c[30]<=new Date("1969-12-31T18:29:58.000-05:30")/\n' +
    '1E3&&((0,c[31])(c[50],c[21]),c[72])((0,c[53])(c[new Date("1969-12-31T22:46:08.000-01:15")/1E3],c[50]),c[3],c[49],c[75]),-10!==c[10]&&(0,c[33])(c[71],(0,c[71])(c[9],c[25]),(0,c[14])(c[84],c[55]),(0,c[23])(c[34],c[82]),c[16],c[55])}try{9>c[60]&&(((0,c[17])(c[34],c[11]),c[23])(c[34],c[59]),1)||(0,c[49])((0,c[17])(c[27],c[5]),c[14],c[12],c[29])}catch(d){(0,c[23])(c[27],c[32])}try{(8===c[500%Math.pow(5,2)+24]||((0,c[49])((0,c[8])(c[27],c[8]),c[51],c[29]),0))&&(0,c[49])((0,c[14])(c[78],c[27]),c[23],c[55],\n' +
    'c[81]),0>c[54]&&((0,c[70])((0,c[31])(c[53],c[61*Math.pow(3,3)+-1589]),c[17],(0,c[74])(c[69+Math.pow(1,4)+-50],c[new Date("1969-12-31T17:15:53.000-06:45")/1E3]),c[27],c[1]),1)||(0,c[49])((0,c[49])((0,c[69])(c[55]),c[23],c[34],c[41]),c[25],c[new Date("1970-01-01T05:00:29.000+05:00")/1E3],(0,c[10])(),c[65]),-1>c[73]&&(0===c[429+Math.pow(6,1)-395]&&((0,c[64])(c[53],c[56])|((0,c[25])(c[34],(0,c[Math.pow(3,1)+135+-86])(),c[65]),c[69])(c[27]),/(,)/)||(0,c[2])((0,c[31])(c[77],c[13]),c[0],(0,c[31])(c[53],\n' +
    'c[26]),c[14],c[22],c[53])),-4===c[57]&&((0,c[58])(c[25],c[50]),1)||(0,c[12])(c[62],c[73])}catch(d){(((0,c[17])(c[3]),(0,c[60])(c[35],(0,c[45])(),c[13]),c[66])(c[25],c[77]),c[60])(c[3],(0,c[15])(),c[13])}}catch(d){return"enhanced_except_65gBlOf-_w8_"+a}return b.join("")};gma(ncode);'

Failed:

  'var nI={QS:function(a){a.reverse()},\n' +
    'UF:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c},\n' +
    'pS:function(a,b){a.splice(0,b)}};var Vsa=function(a){a=a.split("");nI.UF(a,53);nI.pS(a,1);nI.UF(a,28);nI.pS(a,3);nI.UF(a,37);nI.UF(a,21);return a.join("")};Vsa(sig);',
  'var hma=function(a){var b=a.split(""),c=[1280826273,function(){for(var d=64,e=[];++d-e.length-32;)switch(d){case 58:d=96;continue;case 91:d=44;break;case 65:d=47;continue;case 46:d=153;case 123:d-=58;default:e.push(String.fromCharCode(d))}return e},\n' +
    '579928239,1489336969,function(d,e){e.push(d)},\n' +
    '1998819841,1878911005,1282719670,380856459,-184604053,1893237581,function(d,e,f,h,l,m,n){return d(l,m,n)},\n' +
    'b,function(d){d.reverse()},\n' +
    '-1105761364,function(d,e,f){var h=f.length;d.forEach(function(l,m,n){this.push(n[m]=f[(f.indexOf(l)-f.indexOf(this[m])+m+h--)%f.length])},e.split(""))},\n' +
    '1856359654,-1183705349,1075605705,-764745573,-198148851,108243269,1176562466,function(d){for(var e=d.length;e;)d.push(d.splice(--e,1)[0])},\n' +
    'null,"\\u22c2{[",function(d,e){0!=e.length&&(d=(d%e.length+e.length)%e.length,e.splice(0,1,e.splice(d,1,e[0])[0]))},\n' +
    'function(d,e,f,h,l){return e(f,h,l)},\n' +
    '757950715,982836831,1116780763,function(d,e){e=(e%d.length+d.length)%d.length;d.splice(-e).reverse().forEach(function(f){d.unshift(f)})},\n' +
    '-1037131005,1076900753,-1009807228,function(){for(var d=64,e=[];++d-e.length-32;){switch(d){case 58:d-=14;case 91:case 92:case 93:continue;case 123:d=47;case 94:case 95:case 96:continue;case 46:d=95}e.push(String.fromCharCode(d))}return e},\n' +
    '-1170391954,-508934230,function(d){throw d;},\n' +
    '-731869275,-1189565904,b,function(d,e,f,h,l,m){return e(h,l,m)},\n' +
    'function(){for(var d=64,e=[];++d-e.length-32;){switch(d){case 91:d=44;continue;case 123:d=65;break;case 65:d-=18;continue;case 58:d=96;continue;case 46:d=95}e.push(String.fromCharCode(d))}return e},\n' +
    '-1705561953,function(d,e){d=(d%e.length+e.length)%e.length;e.splice(d,1)},\n' +
    '694393475,"bAls",null,-794576283,1895012085,-191831030,null,1998819841,-1893267790,function(d,e,f,h,l,m,n,p){return e(f,h,l,m,n,p)},\n' +
    '1900565512,"3JHA",-1015722618,-1813745988,-216717551,963850155,"[,,,,\\\\",-1275116007,-1184031312,function(d,e){for(d=(d%e.length+e.length)%e.length;d--;)e.unshift(e.pop())},\n' +
    '-1734567079,-1620857930,-323791428,-605779857,function(d,e){e.push(d)},\n' +
    'function(d,e,f,h,l,m,n,p,q){return f(h,l,m,n,p,q)},\n' +
    '-235872796,"[,,,,\\\\",737883914,-371064602,1523647677,function(d,e){if(0!=d.length){e=(e%d.length+d.length)%d.length;var f=d[0];d[0]=d[e];d[e]=f}},\n' +
    'function(d,e){d.splice(d.length,0,e)},\n' +
    '/[/,292,//,-1,/"/],/,2020939673,380856459,-819177349,b,-80287317,function(){for(var d=64,e=[];++d-e.length-32;)switch(d){case 46:d=95;default:e.push(String.fromCharCode(d));case 94:case 95:case 96:break;case 123:d-=76;case 92:case 93:continue;case 58:d=44;case 91:}return e},\n' +
    'function(d,e,f,h,l,m,n,p,q,t,v){return d(f,h,l,m,n,p,q,t,v)},\n' +
    '-198148851,1640174308];c[24]=c;c[48]=c;c[52]=c;try{try{-7>=c[44]&&((0,c[42])((0,c[78])(c[52],c[28]),c[70],(0,c[13])(c[83]),c[55],c[52]),c[27])((0,c[31])(c[83],c[69]),c[65],c[17],c[24]),((0,c[30])(),c[37])(c[68],c[new Date("1970-01-01T08:00:04.000+08:00")/1E3])};hma(ncode);'

notable difference is that success always returns gma and errors always occur on hma.

full body response (failed) for dissection

What happens if we add try catch block on this block?
In this test I simply change the code to:

let decipheredFormats = {};
  var functions = await exports.getFunctions(html5player, options);
  var decipherScript = functions.length ? new vm.Script(functions[0]) : null;
  var nTransformScript;
  try {
    nTransformScript = functions.length > 1 ? new vm.Script(functions[1]) : null;
  } catch (err) {
    if(err.message.includes("Missing catch or finally after try")) {
      console.log(err.message)
    }
  }
    formats.forEach(format => {
      exports.setDownloadURL(format, decipherScript, nTransformScript);
      decipheredFormats[format.url] = format;
  });
  return decipheredFormats;
};

What I noticed is that while ignoring the error, the application actually still downloads the audio albeit at an incredibly snail speeds.
In my test it was running at 0.4Megabits per second. (Incredibly slow)

Not sure what causes it though as debugging it proved to be a bit hard for me as I do not understand how these webscrapers work. But I hope this gave some insights to where the problem could be.

@fpsone
Copy link

fpsone commented Jul 31, 2023

I comeback here because they are digging the old issue #1197 (comment)

I've been using https://github.com/distubejs/ytdl-core fork for a long time and I had no issues with it. This fork is well maintained with fast bug fixes.
npm i @distube/ytdl-core

If you don't want to change your package name, you can overwrite the original package with this command.
npm i ytdl-core@npm:@distube/ytdl-core

@Kinuseka
Copy link

I have been using distube fork of ytdl-core and had been running very smooth for 6 months now. Well maintained and better experience overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants