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

Unexpected reserved word 'await' #285

Open
TheGreyRaven opened this issue Jan 21, 2025 · 10 comments
Open

Unexpected reserved word 'await' #285

TheGreyRaven opened this issue Jan 21, 2025 · 10 comments

Comments

@TheGreyRaven
Copy link

root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:359
    const error = new SyntaxError();
                  ^

SyntaxError: unknown: Unexpected reserved word 'await'. (638:6)

  636 |         return true;
  637 |       };
> 638 |       await _0x1f488e();
      |       ^
  639 |       clearInterval(_0x284d18);
  640 |       _0x284d18 = setInterval(_0x1f488e, 1000);
  641 |       $("#p_div_panel").show();
    at constructor (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:359:19)
    at Parser.raise (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:3327:19)
    at Parser.checkReservedWord (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11878:12)
    at Parser.parseIdentifierName (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11858:12)
    at Parser.parseIdentifier (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11833:23)
    at Parser.parseExprAtom (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11076:27)
    at Parser.parseExprSubscripts (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10734:23)
    at Parser.parseUpdate (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10719:21)
    at Parser.parseMaybeUnary (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10699:23)
    at Parser.parseMaybeUnaryOrPrivate (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10553:61)
    at Parser.parseExprOps (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10558:23)
    at Parser.parseMaybeConditional (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10535:23)
    at Parser.parseMaybeAssign (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10498:21)
    at Parser.parseExpressionBase (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10452:23)
    at /root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10448:39
    at Parser.allowInAnd (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12064:16)
    at Parser.parseExpression (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10448:17)
    at Parser.parseStatementContent (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12508:23)
    at Parser.parseStatementLike (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12375:17)
    at Parser.parseStatementListItem (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12355:17)
    at Parser.parseBlockOrModuleBlockBody (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12929:61)
    at Parser.parseBlockBody (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12922:10)
    at Parser.parseBlock (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12910:10)
    at Parser.parseFunctionBody (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11752:24)
    at Parser.parseFunctionBodyAndFinish (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11738:10)
    at Parser.parseMethod (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11696:31)
    at Parser.parseObjectMethod (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11599:19)
    at Parser.parseObjPropValue (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11630:23)
    at Parser.parsePropertyDefinition (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11570:17)
    at Parser.parseObjectLike (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11485:21)
    at Parser.parseExprAtom (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11000:23)
    at Parser.parseExprSubscripts (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10734:23)
    at Parser.parseUpdate (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10719:21)
    at Parser.parseMaybeUnary (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10699:23)
    at Parser.parseMaybeUnaryOrPrivate (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10553:61)
    at Parser.parseExprOps (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10558:23)
    at Parser.parseMaybeConditional (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10535:23)
    at Parser.parseMaybeAssign (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10498:21)
    at /root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10468:39
    at Parser.allowInAnd (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12069:12)
    at Parser.parseMaybeAssignAllowIn (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10468:17)
    at Parser.parseObjectProperty (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11605:83)
    at Parser.parseObjPropValue (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11630:100)
    at Parser.parsePropertyDefinition (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11570:17)
    at Parser.parseObjectLike (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11485:21)
    at Parser.parseExprAtom (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11000:23)
    at Parser.parseExprSubscripts (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10734:23)
    at Parser.parseUpdate (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10719:21)
    at Parser.parseMaybeUnary (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10699:23)
    at Parser.parseMaybeUnaryOrPrivate (/root/.local/share/fnm/node-versions/v22.13.0/installation/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10553:61) {
  code: 'BABEL_PARSE_ERROR',
  reasonCode: 'UnexpectedReservedWord',
  loc: Position { line: 638, column: 6, index: 21637 },
  pos: 21637,
  syntaxPlugin: undefined
}

I have a quite heavily obfuscated file that fails with the following error shown above.
Not sure what you might need to debug this further, let me know and I can assist with both the file that I'm trying to deobfuscate.

I had a few other files that also contained some awaits and such and those files successfully deobfuscated, so not sure what might be the issue.
Also I'm running the local 2b to deobfuscate.

@0xdevalias
Copy link
Contributor

@TheGreyRaven I would probably start by seeing if bumping to the latest version of @j4k0xb 's webcrack resolves the issue:

If it does, then the version in humanify needs to be updated.

If not and the issue is still present there, then it's probably worth opening an upstream issue and providing an ideally minimal example of the code to reproduce the error:

If not, but it works upstream, then providing an ideally minimal example of the code to reproduce the error here would make the most sense I think.

@TheGreyRaven
Copy link
Author

Ah I see, I tested pasting the obfuscated code into their online ide and there it deobuscated most of the code just fine.
Perhaps a version update would be a good idea!

@0xdevalias
Copy link
Contributor

0xdevalias commented Jan 23, 2025

This project currently seems to be using 2.13.0:

"webcrack": "^2.13.0"

Latest webcrack seems to be 2.15.0:

@TheGreyRaven If you feel like doing a little more digging, it would be useful to know if you get the same error running webcrack directly on version 2.13.0, and which newer version seems to fix it. That would help provide relevant context for this bug report.

@j4k0xb
Copy link
Contributor

j4k0xb commented Jan 23, 2025

I remember a similar discussion regarding the version in this repo
It should already use the latest version due to the ^?

Since it works fine the first time I assume the generated code get's corrupted at some point.
Remember that the babel parser is used by humanify itself, webcrack, and prettier.

@brianjenkins94
Copy link

You can use overrides for quick testing:

#67 (comment)

@VivaLaPanda
Copy link

With overriding to latest webcrack, I still see this

@0xdevalias
Copy link
Contributor

With overriding to latest webcrack, I still see this

@VivaLaPanda Thanks for checking.

If not, but it works upstream, then providing an ideally minimal example of the code to reproduce the error here would make the most sense I think.

@TheGreyRaven / @VivaLaPanda Since it sounds like the issue is in humanify rather than webcrack, it would be useful to have an (ideally minimal, but any is better than none) example code that triggers this error; to help narrow down exactly where it's being caused.

@fosteman
Copy link

fosteman commented Feb 7, 2025

this seems to fix it:

main...fosteman:humanify:main

although, i am skipping the problem instead of dealing with it.

@0xdevalias
Copy link
Contributor

0xdevalias commented Feb 7, 2025

this seems to fix it:

main...fosteman:humanify:main

This seems to create a plugin that logs a console.error, and then skips the entire Program:

const syntaxErrorPlugin: PluginItem = {
  visitor: {
    Program(path) {
      // Example: this would log an error and allow Babel to continue parsing
      console.error("Syntax error encountered. skipping", path);
      path.skip();
    }
  }
};

Which is then added at the end of transformWithPlugins.

@fosteman Can you explain how this fixes the issue? From my quick / naive read.. this looks like it would just skip running any processing against the code at all; so while yes, it would technically skip the issue, I believe it would also skip doing anything at all wouldn't it?

Do you have a code sample where this issue was natively occurring? I would like someone to be able to provide a real-world sample so we can actually debug this issue properly and see exactly where/why it's occurring.


Edit: Resurrecting the stack trace from your edit:

Stack Trace
Processing file 1/538
Processing: 100%
Processing file 2/538
/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:360
const error = new SyntaxError();
^

SyntaxError: unknown: Unexpected reserved word 'await'. (3:4)

1 | module.exports = {
2 | showProjectGroupAccessDeniedModal() {
> 3 | await swal.fire({
| ^
4 | icon: "error",
5 | title: "Access Denied",
6 | text: "You don't have the required permissions to access this project group.",
at constructor (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:360:19)
at Parser.raise (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:3327:19)
at Parser.checkReservedWord (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11899:12)
at Parser.parseIdentifierName (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11879:12)
at Parser.parseIdentifier (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11854:23)
at Parser.parseExprAtom (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11090:27)
at Parser.parseExprSubscripts (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10748:23)
at Parser.parseUpdate (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10733:21)
at Parser.parseMaybeUnary (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10713:23)
at Parser.parseMaybeUnaryOrPrivate (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10566:61)
at Parser.parseExprOps (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10571:23)
at Parser.parseMaybeConditional (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10548:23)
at Parser.parseMaybeAssign (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10511:21)
at Parser.parseExpressionBase (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10465:23)
at /Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10461:39
at Parser.allowInAnd (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12085:16)
at Parser.parseExpression (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10461:17)
at Parser.parseStatementContent (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12529:23)
at Parser.parseStatementLike (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12396:17)
at Parser.parseStatementListItem (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12376:17)
at Parser.parseBlockOrModuleBlockBody (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12950:61)
at Parser.parseBlockBody (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12943:10)
at Parser.parseBlock (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12931:10)
at Parser.parseFunctionBody (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11773:24)
at Parser.parseFunctionBodyAndFinish (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11759:10)
at Parser.parseMethod (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11717:31)
at Parser.parseObjectMethod (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11620:19)
at Parser.parseObjPropValue (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11651:23)
at Parser.parsePropertyDefinition (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11591:17)
at Parser.parseObjectLike (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11506:21)
at Parser.parseExprAtom (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:11014:23)
at Parser.parseExprSubscripts (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10748:23)
at Parser.parseUpdate (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10733:21)
at Parser.parseMaybeUnary (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10713:23)
at Parser.parseMaybeUnaryOrPrivate (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10566:61)
at Parser.parseExprOps (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10571:23)
at Parser.parseMaybeConditional (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10548:23)
at Parser.parseMaybeAssign (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10511:21)
at Parser.parseMaybeAssign (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10537:25)
at Parser.parseExpressionBase (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10465:23)
at /Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10461:39
at Parser.allowInAnd (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12085:16)
at Parser.parseExpression (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:10461:17)
at Parser.parseStatementContent (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12529:23)
at Parser.parseStatementLike (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12396:17)
at Parser.parseModuleItem (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12373:17)
at Parser.parseBlockOrModuleBlockBody (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12950:36)
at Parser.parseBlockBody (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12943:10)
at Parser.parseProgram (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12270:10)
at Parser.parseTopLevel (/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:12260:25) {
code: 'BABEL_PARSE_ERROR',
reasonCode: 'UnexpectedReservedWord',
loc: Position { line: 3, column: 4, index: 63 },
pos: 63,
syntaxPlugin: undefined
}

Node.js v18.20.3

We can see this part of the error, showing the code that caused it:

Processing file 1/538
Processing: 100%
Processing file 2/538
/Users/REDACTED/.nvm/versions/node/v18.20.3/lib/node_modules/humanifyjs/node_modules/@babel/parser/lib/index.js:360
const error = new SyntaxError();
^

SyntaxError: unknown: Unexpected reserved word 'await'. (3:4)

  1 | module.exports = {
  2 | showProjectGroupAccessDeniedModal() {
> 3 |   await swal.fire({
    |   ^
  4 |     icon: "error",
  5 |     title: "Access Denied",
  6 |     text: "You don't have the required permissions to access this project group.",

Putting the whole stack trace into ChatGPT 4o gave the following suggestion about the root cause of the error:

Yes, the stack trace does indicate an issue in your app code, even though the error originates from Babel. Specifically, the issue is:

SyntaxError: unknown: Unexpected reserved word 'await'. (3:4)

This points to the following section of your code:

  1 | module.exports = {
  2 | showProjectGroupAccessDeniedModal() {
> 3 | await swal.fire({
    | ^

What This Means:

  • The await keyword is used inside showProjectGroupAccessDeniedModal(), but the function is not declared as async.
  • Babel is failing while parsing your code because await can only be used inside an async function.

How to Fix:

Modify your function to be async:

module.exports = {
  async showProjectGroupAccessDeniedModal() {
    await swal.fire({
      icon: "error",
      title: "Access Denied",
      text: "You don't have the required permissions to access this project group.",
    });
  }
};

Why Babel is Involved:

Babel is responsible for parsing and transpiling your JavaScript, and it's throwing this error because the await keyword is misused. However, the actual problem is in your application code, not Babel itself.

So, fixing your function should resolve the issue. 🚀

@0xdevalias
Copy link
Contributor

0xdevalias commented Feb 7, 2025

@TheGreyRaven The surrounding context in your error is less clear than what I discovered above in #285 (comment), but I suspect it's the same root cause, that there is an await keyword in your code, but the function isn't marked with async. If you still have the code sample available, are you able to check if that is true please?

SyntaxError: unknown: Unexpected reserved word 'await'. (638:6)

  636 |         return true;
  637 |       };
> 638 |       await _0x1f488e();
      |       ^
  639 |       clearInterval(_0x284d18);
  640 |       _0x284d18 = setInterval(_0x1f488e, 1000);
  641 |       $("#p_div_panel").show();

While I haven't yet explored this deeper, my potential guesses for areas to look deeper would be:

  • the original code sample never had the function marked with async before using await internally
  • perhaps during renaming of the outer function, humanify is removing the async keyword
  • perhaps during renaming of the inner function, humanify is choosing a name that includes async as a prefix (despite that being an invalid name)

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

6 participants