You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeError: Cannot read property 'traitIds' of undefined
at linearize (...src/lib/world-object-proxy-builder.js:5:9)
at target.traitIds.forEach.traitId (...src/lib/world-object-proxy-builder.js:8:5)
at Array.forEach (native)
at linearize (...src/lib/world-object-proxy-builder.js:5:19)
at Handler.get (...src/lib/world-object-proxy-builder.js:65:21)
at output (...src/lib/print.js:47:39)
at print (...src/lib/print.js:105:5)
at printHelper (...src/lib/print.js:110:10)
at ProgrammerController.onEval (...src/controllers/programmer-controller.js:23:27)
at PlayerController.onInput (...src/controllers/player-controller.js:24:40)
That's kind of an embarrassment, as even all() breaks with the same error afterwards. One workaround is to manually reset the traits of the all offending children nodes (e.g. stuff2.traits = []), but you might not know/remember which it/them (e.g. the parent's destruction might even have been done by somebody else).
I experimented with the following graceful handling for this degraded case:
function linearize(object, linearization = new C3(object)) {
object.traits.forEach((trait, index) => {
if (trait !== undefined) {
linearization.add(object, trait);
linearize(trait, linearization);
} else {
// Attempt at gracefully handle broken trait chain
object.traits.splice(index, 1);
}
});
return linearization.run();
}
Seems to work on my local copy, unless I've missed any edge case... Would that be an appropriate fix/workaround, or is there a better way to handle this case ?
(For the record, another idea for a brief moment was to check all objects for possible dependency and reject the .destroy() call in that case, but don't think it's performance-wise.)
The text was updated successfully, but these errors were encountered:
Omikhleia
added a commit
to Omikhleia/room.js
that referenced
this issue
Aug 16, 2016
Let's do this:
And we get:
That's kind of an embarrassment, as even all() breaks with the same error afterwards. One workaround is to manually reset the traits of the all offending children nodes (e.g.
stuff2.traits = []
), but you might not know/remember which it/them (e.g. the parent's destruction might even have been done by somebody else).I experimented with the following graceful handling for this degraded case:
Seems to work on my local copy, unless I've missed any edge case... Would that be an appropriate fix/workaround, or is there a better way to handle this case ?
(For the record, another idea for a brief moment was to check all objects for possible dependency and reject the .destroy() call in that case, but don't think it's performance-wise.)
The text was updated successfully, but these errors were encountered: