question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'defs' of undefined

See original GitHub issue

Obfuscation crashes when run via webpack-obfuscator (stack trace below) with latest version (0.24.2)

Reverting to 0.23.2 fixes issue.

Your Environment

  • Obfuscator version used: 0.24.2
  • Node version used: 13.6.0

Stack trace

TypeError: Cannot read property 'defs' of undefined
    at find (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/analyzers/scope-analyzer/ScopeAnalyzer.ts:76:72)
    at Array.find (<anonymous>)
    at forEach (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/analyzers/scope-analyzer/ScopeAnalyzer.ts:74:22)
    at Array.forEach (<anonymous>)
    at o.sanitizeScopes (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/analyzers/scope-analyzer/ScopeAnalyzer.ts:71:27)
    at o.sanitizeScopes (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/analyzers/scope-analyzer/ScopeAnalyzer.ts:84:18)
    at o.acquireScope (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/analyzers/scope-analyzer/ScopeAnalyzer.ts:67:14)
    at o.transformNode (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/node-transformers/obfuscating-transformers/ScopeIdentifiersTransformer.ts:61:48)
    at visitorFunction (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/node-transformers/obfuscating-transformers/ScopeIdentifiersTransformer.ts:49:41)
    at Controller.<anonymous> (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/node-transformers/TransformersRunner.ts:98:39)
    at Controller.__execute (/usr/src/app/node_modules/estraverse/estraverse.js:330:31)
    at Controller.replace (/usr/src/app/node_modules/estraverse/estraverse.js:570:27)
    at Object.replace (/usr/src/app/node_modules/estraverse/estraverse.js:651:27)
    at N.transform (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/node-transformers/TransformersRunner.ts:73:24)
    at o.runTransformationStage (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/JavaScriptObfuscator.ts:103:40)
    at o.transformAstTree (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/JavaScriptObfuscator.ts:82:24)
    at obfuscate (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/JavaScriptObfuscator.ts:51:40)
    at Function.obfuscate (/usr/src/app/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/JavaScriptObfuscatorFacade.ts:12:53)
    at WebpackObfuscator.obfuscate (/usr/src/app/node_modules/webpack-obfuscator/dist/index.js:61:67)
    at /usr/src/app/node_modules/webpack-obfuscator/dist/index.js:30:77
    at Array.forEach (<anonymous>)
    at /usr/src/app/node_modules/webpack-obfuscator/dist/index.js:24:29
    at Array.forEach (<anonymous>)
    at /usr/src/app/node_modules/webpack-obfuscator/dist/index.js:23:32
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/src/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook (/usr/src/app/node_modules/tapable/lib/Hook.js:154:20)
    at Compiler.emitAssets (/usr/src/app/node_modules/webpack/lib/Compiler.js:491:19)
    at onCompiled (/usr/src/app/node_modules/webpack/lib/Compiler.js:278:9)
    at /usr/src/app/node_modules/webpack/lib/Compiler.js:681:15
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/src/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (/usr/src/app/node_modules/tapable/lib/Hook.js:154:20)
    at /usr/src/app/node_modules/webpack/lib/Compiler.js:678:31
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/src/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (/usr/src/app/node_modules/tapable/lib/Hook.js:154:20)
    at /usr/src/app/node_modules/webpack/lib/Compilation.js:1423:35
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/src/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
jeromewircommented, Jan 30, 2020

Confirmed working for me too with 0.24.3, thanks a lot for the quick fix!

1reaction
cobrowse-enterprisecommented, Jan 29, 2020

Fixed for me, thanks for such a quick response!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Minimal example throws "Cannot read property 'definitions' of ...
I'm trying to create a minimal GraphQL server example using Apollo Server. However, when I make a request to it, it responds with...
Read more >
Error when building typedefs TypeError: Cannot read property ...
I am getting the following error when building Typedefs in Apollo Server: return typeDef.definitions.some( ...
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >
TypeError: Cannot read property 'close' of undefined - MongoDB
I had this problem, I t changed the connectTimeoutMS variable in mongoclient.spec.js to 2000 (this is defined twice in the file. make sure...
Read more >
Fix: “Cannot Read Property of Undefined” Error in JavaScript
To fix the “cannot read property of undefined” error, use the optional chaining operator on the variable before accessing a property. If the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found