
Testcase: on('chat:message', msg => {
if(msg.type === 'api' && msg.content === '!test') {
const handout = createObj('handout', {name: 'test', notes:'testNotes'});
log(handout);
handout.get('notes', notes => handout.set('notes', notes + 'extra'));
}
});
I would expect that running !test would create a handout with the text 'testNotes' and then immediately append 'extra' to the text. In practice, this breaks in two ways. First of all (and this is behaviour that I've seen in other scripts as well), the resulting text of the handout is 'nullextra', and the log output shows that the handout actually has the notes populated directly on the object after creation. This remains true for objects created with a notes attribute even if you restart the API and get the object back by id - it is permanently incorrect. As soon as you call .set('notes', value), however, the contents of the notes field are removed and replaced with a number, and from then onwards can only be accessed asynchronously. Obviously this inconsistency is rather unhelpful. The second problem is that the script above actually crashes the API : RangeError: Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:18)
at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:133)
at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:392)
at $a.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:26:392)
at Ua.t.remove (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:21:402)
at O.t.J (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:40:559)
at O.t.Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:40:752)
at O.t.Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:40:728)
at U (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:92:256)
at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:108 I'm not sure what the exact criteria are for the crash - my testcase produces it reliably - but it appears incidental to the other issue.