Uncaught ReferenceError: test is not defined
See original GitHub issueversion: tested with both 2.6.3
and 2.8.0
I’m getting a Uncaught ReferenceError: test is not defined
that I cannot understand. I’ve done a lot of testing and I can tell so far:
- seems to be related to code using
async
- the error always is caused by trying to use a variable called exactly
test
- the error seems to happen in different parts of my code, changing the point where it happens as I produce different builds (I’m using the webpack-obfuscator for this)
- I don’t have a property or variable named
test
in any part of my code - the error only happens if
controlFlowFlattening: true
ANDselfDefending: true
- I’m testing using the
seed
option. With some seeds the error never occurs; with others, it always occurs
Obfuscated snippet (this is just the top of the file, there is more functions later but they don’t seem to be relevant here - I can send it if needed, preferably privately). The error occurs at test['constructor']
:
import _0x3317b2 from '../conf';
function _await(_0x55ad0d, _0x74fe2a, _0x56a29b) {
if (_0x56a29b)
return _0x74fe2a ? _0x74fe2a(_0x55ad0d) : _0x55ad0d;
return (!_0x55ad0d || !_0x55ad0d['then']) && (_0x55ad0d = Promise['resolve'](_0x55ad0d)),
_0x74fe2a ? _0x55ad0d['then'](_0x74fe2a) : _0x55ad0d;
}
function _async(_0x39e875) {
const _0x256514 = function() {
let _0x57d75a = !![];
return function(_0x2ab882, _0x3ca6b0) {
const _0x30cf38 = _0x57d75a ? function() {
if (_0x3ca6b0) {
const _0x46535c = _0x3ca6b0['apply'](_0x2ab882, arguments);
return _0x3ca6b0 = null,
_0x46535c;
}
}
: function() {}
;
return _0x57d75a = ![],
_0x30cf38;
}
;
}()
, _0x282d2a = _0x256514(this, function() {
const _0x246224 = function() {
const _0x3fc13d = test['constructor']('return\x20/\x22\x20+\x20this\x20+\x20\x22/')()['constructor']('^([^\x20]+(\x20+[^\x20]+)+)+[^\x20]}');
return !_0x3fc13d['test'](_0x282d2a);
};
return _0x246224();
});
return _0x282d2a(),
function() {
for (var _0x150116 = [], _0x3429a4 = 0x0; _0x3429a4 < arguments['length']; _0x3429a4++) {
_0x150116[_0x3429a4] = arguments[_0x3429a4];
}
try {
return Promise['resolve'](_0x39e875['apply'](this, _0x150116));
} catch (_0x30fc7a) {
return Promise['reject'](_0x30fc7a);
}
}
;
}
export const getResult = _async(function(_0x1f8d7f) {
const _0x5c05b5 = {
'ApnJM': 'BACKEND_URL'
}
, _0x544bdb = _0x3317b2(_0x5c05b5['ApnJM']) + '/result/' + _0x1f8d7f
, _0xe8ce2e = {
'method': 'GET',
'credentials': 'include'
};
return _await(fetch(_0x544bdb, _0xe8ce2e), function(_0x1632a6) {
if (!_0x1632a6['ok'])
throw new CustomError(_0x1632a6['status']);
return _0x1632a6['json']();
});
});
// there is more code, but I don't think is needed
Config (my intention is to enable everything that is false
below, I’ve just disabled it to isolate the problem):
options: {
seed: 2,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.1,
identifierNamesGenerator: 'hexadecimal',
selfDefending: true,
splitStrings: false,
shuffleStringArray: false,
rotateStringArray: false,
stringArray: false,
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Uncaught ReferenceError: test (function) is not defined
I am getting the Uncaught ReferenceError: test (function) is not defined error in Google Chrome. Following is the simplest of functions that I ......
Read more >Uncaught ReferenceError: test (function) is not defined
This appears to be an order of execution problem. The file containing the test function needs to be referenced before the inline JS...
Read more >ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
The JavaScript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere.
Read more >jQuery - Validation Test Suite - Willet Law Office
Uncaught ReferenceError : jQuery is not defined@ 3 ms ... ://willetlaw.com/include/scripts/jquery-validation-master/test/rules.js:3:1: $ is not defined@ 3 ms ...
Read more >ATF - ReferenceError: test is not defined - ServiceNow
ATF - ReferenceError: test is not defined ... Hello there,. I am trying to do the simplest of tests (well, test steps). ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It works perfectly! Thanks a lot 👍
Fixed in
javascript-obfuscator@2.8.1