This is a long one.
So, `instanceof` in Typescript is incredibly flimsy. There's a
documented bug with what happens when you extend built-in classes, such
as Error or Array. You can read more about it here: https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work
However, this normally works fine. A previous commit moved some schemas
from server/ to common/, our gameSpecific UGPT settings schemas. This
caused them to break in an interesting way. For any schema recursive
with a depth greater than 1, all errors would be ignored. Why on earth
was this happening?
Well Prudence passes errors up the stack with a "return Err" -> "if
ret instanceof Err: return Err" kind of approach. This normally works
fine.
The real kicker here is that because server/ and common/ were on 0.9.7
and 0.9.8 respectively, the "Err" instance in question would actually be
erased when ran at runtime. The "if ret instance of Err" would fail,
because the Err would be from 0.9.7, not 0.9.8. This subtle difference
in file results in catastrophic damage.
In short. InstanceOf is a footgun. I hate it. Lets never do it again.
Thanks.
this allows ANY_INF to be passed as a difficulty, which is convenient
for scripts that import from services that consider all of INF/GRV/HVN...
to be equivalent
Honestly, not sure why this exists and why the cap
is so low. Maybe some node guy can explain this to me.
Ah well. We don't execute anything that should DOS us
and we certainly don't let user input hit this function
so, we should be good.
future employers, please ignore this small mishap on part of the
contributor. Consider hiring them, they're very good at their job
and make excellent coffees.
it's completely broken and no longer honoured. I *still* to this day do
not know why this is a bug on our systems. Maybe I will investigate it
further at some point, but for now, instanceof is banned in the codebase
as it doesn't seem to fucking work.
normally i refrain from swearing in a codebase i know future employers
will check, but this has to be one of *the* most frustrating bugs we've
had in years.