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

Missing catch or finally after try - this error is back in 4.11.4 as well #1216

Open
arian0gen opened this issue Apr 26, 2023 · 16 comments
Open

Comments

@arian0gen
Copy link

evalmachine.:24
c[74]),c[64])((0,c[25])(c[24],c[41]),c[35],c[33+Math.pow(8,3)%229],c[92]),c[70])(c[87],c[27])}try{8>=c[92]&&(0,c[15])((0,c[35])(c[36],c[20]),c[11],c[29])}catch(d){(0,c[60])(c[92],c[93])}try{1>c[45]?((0,c[60])(c[2],c[93]),c[60])(c[91],c[93]):((0,c[88])(c[93],c[86]),c[11])(c[57])}catch(d){(0,c[85])((0,c[80])(),c[56],c[0])}};qma(ncode);

                                 ^

SyntaxError: Missing catch or finally after try

@ZKillou
Copy link

ZKillou commented Apr 26, 2023

Same issue here. It happens but not every time.

Edit : You can use 4.10.0, it works but is kinda slow.

@Kisakay
Copy link

Kisakay commented Apr 26, 2023

I have the same issue :
evalmachine.:24
c[74]),c[64])((0,c[25])(c[24],c[41]),c[35],c[33+Math.pow(8,3)%229],c[92]),c[70])(c[87],c[27])}try{8>=c[92]&&(0,c[15])((0,c[35])(c[36],c[20]),c[11],c[29])}catch(d){(0,c[60])(c[92],c[93])}try{1>c[45]?((0,c[60])(c[2],c[93]),c[60])(c[91],c[93]):((0,c[88])(c[93],c[86]),c[11])(c[57])}catch(d){(0,c[85])((0,c[80])(),c[56],c[0])}};qma(ncode);

@danisty
Copy link

danisty commented Apr 26, 2023

Exact same issue and error as the one mentioned above me.

@Sansekai
Copy link

provisionally im using https://www.npmjs.com/package/@distube/ytdl-core work for me

Try this:
"ytdl-core": "npm:@distube/ytdl-core",

@ShadowLp174
Copy link

Happened a few hours ago a few times, then it worked again, now it's broken again

@ShadowLp174
Copy link

ShadowLp174 commented Apr 26, 2023

@Sansekai

provisionally im using https://www.npmjs.com/package/@distube/ytdl-core work for me

Try this: "ytdl-core": "npm:@distube/ytdl-core",

Don't forget to add the version number ^4.11.9

"ytdl-core": "npm:@distube/ytdl-core@^4.11.9"

@arian0gen
Copy link
Author

this exact error was 2 weeks ago in 4.11.3 and then we freaked out, and then they fixed and now it is back again, it is probably because youtube keep changing their code so...

@nukeop
Copy link

nukeop commented Apr 26, 2023

This fork uses some custom HTTP client that doesn't play ball when you mock fetch in tests: https://www.npmjs.com/package/undici

It works in practice but it ruins all my test suites.

@danisty
Copy link

danisty commented Apr 26, 2023

After some research I've found that the problem has to do with the signature deciphering extraction of functions, specifically the extractNCode function, when calling cutAfterJS it fails to escape the following string /[/,-33,/,/]{/,function due to the literal / characters inside a RegEx character set, and so it counts opening and closing brackets incorrectly as it treats most part of the code as a regular expression, resulting in the script not getting to the end of the function and missing a catch block and a return statement.

TEMP FIX
Add a check for RegEx character sets, replace

// Go through all characters from the start
for (i = 0; i < mixedJson.length; i++) {
// End of current escaped object
if (!isEscaped && isEscapedObject !== null && mixedJson[i] === isEscapedObject.end) {
isEscapedObject = null;
continue;

with

  // Go through all characters from the start
  for (i = 0; i < mixedJson.length; i++) {
    // End of current escaped object
    if (!isEscaped && isEscapedObject !== null && mixedJson[i] === isEscapedObject.end) {
      // Ignore character inside RegEx character set with a range of 30 characters
      let charsetStart = mixedJson.substring(i - 15, i).search(/\[[^\]]*/)
      let charsetEnd = mixedJson.substring(i, i + 15).search(/[^\[]*\]/)
      if (mixedJson[i] == '/' && charsetStart !== -1 && charsetEnd !== -1)
        continue;

      isEscapedObject = null;
      continue;

You can find the file locally in ./node_modules/ytdl-core/lib/utils.js

@dim4ik1106
Copy link

After some research I've found that the problem has to do with the signature deciphering extraction of functions, specifically the extractNCode function, when calling cutAfterJS it fails to escape the following string /[/,-33,/,/]{/,function due to the literal / characters inside a RegEx character set, and so it counts opening and closing brackets incorrectly as it treats most part of the code as a regular expression, resulting in the script not getting to the end of the function and missing a catch block and a return statement.

TEMP FIX Add a check for RegEx character sets, replace

// Go through all characters from the start
for (i = 0; i < mixedJson.length; i++) {
// End of current escaped object
if (!isEscaped && isEscapedObject !== null && mixedJson[i] === isEscapedObject.end) {
isEscapedObject = null;
continue;

with

  // Go through all characters from the start
  for (i = 0; i < mixedJson.length; i++) {
    // End of current escaped object
    if (!isEscaped && isEscapedObject !== null && mixedJson[i] === isEscapedObject.end) {
      // Ignore character inside RegEx character set with a range of 30 characters
      let charsetStart = mixedJson.substring(i - 15, i).search(/\[[^\]]*/)
      let charsetEnd = mixedJson.substring(i, i + 15).search(/[^\[]*\]/)
      if (mixedJson[i] == '/' && charsetStart !== -1 && charsetEnd !== -1)
        continue;

      isEscapedObject = null;
      continue;

You can find the file locally in ./node_modules/ytdl-core/lib/utils.js

This works for me. I made a patch with this changes, so you can use it with
"ytdl-core": "git+https:/dim4ik1106/node-ytdl-core.git#master",

@khlevon
Copy link
Contributor

khlevon commented Apr 27, 2023

To make your code work you can use this patch

"ytdl-core": "git+ssh://[email protected]:khlevon/node-ytdl-core.git#v4.11.4-patch.1"

XimTheCookie added a commit to XimTheCookie/WhaproBot that referenced this issue Apr 27, 2023
Changed version to ytdl-core patch since there was a problem with version 4.11.4.
fent/node-ytdl-core#1216
@MeLikeApplez
Copy link

UnhandledPromiseRejectionWarning: Error: Could not parse decipher function: TypeError: decipherFuncName.replaceAll is not a function
Apr 27 10:07:58 PM at extractDecipher (/opt/render/project/src/node_modules/ytdl-core/lib/sig.js:92:13)
Apr 27 10:07:58 PM at Object.exports.extractFunctions (/opt/render/project/src/node_modules/ytdl-core/lib/sig.js:126:3)
Apr 27 10:07:58 PM at /opt/render/project/src/node_modules/ytdl-core/lib/sig.js:22:29
Apr 27 10:07:58 PM at runMicrotasks ()
Apr 27 10:07:58 PM at processTicksAndRejections (internal/process/task_queues.js:95:5)

@nezort11
Copy link

To make your code work you can use this patch

"ytdl-core": "git+ssh://[email protected]:khlevon/node-ytdl-core.git#v4.11.4-patch.1"

For me this syntax worked:

"ytdl-core": "https:/khlevon/node-ytdl-core.git#v4.11.4-patch.1"

@khlevon
Copy link
Contributor

khlevon commented Apr 28, 2023

To make your code work you can use this patch

"ytdl-core": "git+ssh://[email protected]:khlevon/node-ytdl-core.git#v4.11.4-patch.1"

In case someone needs to have node 12 and 14 support, you can use this patch

"ytdl-core": "git+ssh://[email protected]:khlevon/node-ytdl-core.git#v4.11.4-patch.2"

For more details check this PR: #1217
Also, do not hesitate to review the code and write comments or approve it :)

@fpsone
Copy link

fpsone commented May 24, 2023

@Sansekai

provisionally im using https://www.npmjs.com/package/@distube/ytdl-core work for me
Try this: "ytdl-core": "npm:@distube/ytdl-core",

Don't forget to add the version number ^4.11.9

"ytdl-core": "npm:@distube/ytdl-core@^4.11.9"

4.11.9 cannot play some streams, I updated to 4.11.10 and it's working normally

npm i ytdl-core@npm:@distube/ytdl-core@latest

@ledlamp
Copy link

ledlamp commented Jul 29, 2023

4.11.5 same issue

npm install khlevon/node-ytdl-core.git#v4.11.4-patch.1 work

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