Lodash instance on servers broken
-
Not sure how this even can happen, but the version of Lodash on the server appears to be broken.
I've been using the following code to count creep body parts:
`_(body).countBy().thru(s => JSON.stringify(s))`
This worked up until about an hour ago, and now suddenly I get an error every time a creep spawns:
`TypeError: _(...).countBy(...).thru is not a function`
It looks like now, in a chain, `countBy` suddenly returns a number, instead of a chain object to call further methods on (or even the right result from countBy!)
Can you look into this? I can obviously work around it by not using chains here, but I don't want to scour my code to find all the other more subtle bugs that were just introduced by this brokenness, and I'm worried about what other functions might be similarly broken.
Thanks!
Edit: This is now fixed. Thanks guys.
Edit 2: It's back! I guess I'm going to have to upload my own lodash so this craziness doesn't affect me.
-
How about body.length ?
-
Did you even check what groupBy does? It's not the same thing in any way. And again, this probably isn't just groupBy that's the problem, there are likely several other issues that are more subtle.
I'm really frustrated right now. I tried uploading my own lodash but it costs 30 CPU on every global reset to load it, which is clearly unacceptable. So now I have to put up with a sometimes-broken library or not use it at all, neither of which makes me happy in the least.
Can we get a fix for this issue? Or maybe get a way that we can upload our own lodash that doesn't cost us huge amounts of CPU to use?
-
There indeed seems to be something wrong with the lodash implementation.
The following line gives correct output when entered into the console, but not when executed from within the code ...
_((123456).toString()).toArray().reverse().chunk(3).forEachRight(s=>console.log(s));
I agree, that's something which should get some attention!
-
Also, given that occasionally we get what I have dubbed "reset storms" (periods of time where global resets are very common), uploading an entire major library is infeasible - paying that extra 30 CPU cost once every couple hundred ticks is at least doable; every four ticks not so much.
-
We've figured out this issue. There was a bug which caused modifications of the lodash object made by one player to appear in another player's code. It is fixed, every player now receives an isolated pristine lodash instance.
-
Great! thx
-
Fantastic. Sounds scary, glad it didn't cause too much havoc
I can imagine someone replacing _.filter with function() { _(Game.creeps).values().forEach(c => c.suicide); }.