Non-UserCodeError: TypeError: undefined is not a function

I’ve submitted code which triggers a console error of “Non-UserCodeError: TypeError: undefined is not a function”

This causes the game to never load, and I can’t seem to enter a game to attempt to fix.

Full trace

|Athena's Archer| Non-UserCodeError: TypeError: undefined is not a function
TypeError: undefined is not a function
    at new t (http://codecombat.com/javascripts/world.js:1279:173)
    at t.i.exports.t.getState (http://codecombat.com/javascripts/world.js:1265:75)
    at t.i.exports.t.setState (http://codecombat.com/javascripts/world.js:1406:94)
    at new t (http://codecombat.com/javascripts/world.js:1402:135)
    at t.i.exports.t.getNextFrame (http://codecombat.com/javascripts/world.js:1405:10)
    at World.module.exports.World.getFrame (http://codecombat.com/javascripts/world.js:1330:52)
    at World.module.exports.World.loadFrames (http://codecombat.com/javascripts/world.js:1337:71)
    at http://codecombat.com/javascripts/world.js:1338:339 

Edit:

Managed to test code on another account. This happens if I try to modify a coins properties (specifically pos). I see now that these are read only properties, but attempting to change them shouldn’t crash the game (and make it impossible to fix :frowning:) .

I still can’t get to an edit panel on my account so if you could clear my code it would be appreciated.

Recovered, sorry about that. Working to make the error recoverable now.

I got Inifinite code warning during loading of Zero Sum level (one of my lost battles). Battle playback failed with following error:

|Tengri’s Cyril| Loaded 463 of 960 (+1263ms)
(program):6 |Tengri’s Cyril| Loaded 469 of 960 (+1066ms)
(program):6 |Tengri’s Cyril| Non-UserCodeError: TypeError: undefined is not a function
TypeError: undefined is not a function
at t.eval (eval at (http://codecombat.com/javascripts/world.js:329:20), :144:65)
at t.CastsRaiseDead.raisedChooseAction [as chooseAction] (eval at (http://codecombat.com/javascripts/world.js:329:20), :149:8)
at Action.update (eval at (http://codecombat.com/javascripts/world.js:329:20), :41:19)
at t.e.exports.t.getNextFrame (http://codecombat.com/javascripts/world.js:391:100)
at World.module.exports.World.getFrame (http://codecombat.com/javascripts/world.js:293:52)
at World.module.exports.World.loadFrames (http://codecombat.com/javascripts/world.js:302:10)
at http://codecombat.com/javascripts/world.js:299:172
(program):24 Uncaught TypeError: Cannot read property ‘shift’ of null
(program):6 |Tengri’s Cyril| Worker initialized after 1058ms
2(program):645 Cannot show action build for Gold Cloud because it DNE
(program):645 Cannot show action mana-blast for Sorcerer because it DNE

1 Like

How about now? I just made the raise-dead logic a little more robust to raising dead units that can’t see, but I’m not sure that was it. (Did you raise a chest or something, possibly?)

1 Like

@Nick, thanks for a fast fix. I’ve checked a dozen of fights, no sight of that issue

This is a common JavaScript error that happens when you try to call a function before it is defined. You get “‘undefined’ is not a function” error when you try to execute a function that is uninitialized or improperly initialized . It means that the expression did not return a function object. So you have to figure out what you are trying to execute isn’t a function.

In Javascript , when you execute a function, it’s evaluated like the following:

  • expression.that(‘returns’).aFunctionObject(); // js
  • execute -> expression.that(‘returns’).aFunctionObject // what the JS engine does

That expression may be complex. So when you get undefined is not a function it means that expression did not return a function object. So you have to figure out what you are trying to execute isn’t a function.