I've got an error that doesn't always replicate and is hard for me to figure out.
The situation: I have a hidden variable called runeBag with an initial value of "[]". This variable keeps track of the "runes" that have been tied to active abilities and is intended to store those as an array. The runeBag variable can be grabbed by a companion script and then the script does stuff with it. This is the sheetworker code
// This handels keeping a running list of which runes have been used const runes = ["void", "fehu", "uruz", "thurisaz","cansuz", "raidho", "kenaz", "gebgift", "wunjo", "hagalaz", "naudhneed", "isaice", "jethe", "eihwas", "pertho", "elhaz", "sowsun", "tiwaz", "berkano", "ehwo", "mann", "claguz", "dagaz", "ing", "othala", "physical", "mental", "spiritual"] on("change:repeating_actives", (eventInfo) => { //setAttrs({"runeBag": [1,1,3]}); //console.log(eventInfo); //console.log(eventInfo.newValue); if (_.contains(runes, eventInfo.newValue) || _.contains(runes, eventInfo.previousValue)) { getAttrs(["runeBag"], v => { //console.log(v.runeBag); if (!(_.isArray(v.runeBag))) { //console.log("not array"); var bag = JSON.parse(v.runeBag); } else { var bag = v.runeBag; } //console.log(bag); //console.log(_.isArray(bag)); if (eventInfo.newValue == 0) { //console.log("new value 0") var bag = _.difference(bag, [eventInfo.previousValue]); //console.log(bag); } else if (!(_.contains(bag, eventInfo.newValue)) && eventInfo.newValue != "void") { bag.push(eventInfo.newValue); //console.log(bag); } //console.log(bag); setAttrs({"runeBag": bag}); }); } })
It seems that for some characters the runeBag variable is being stored correctly as an array while for others it is being stored as a string. In the ones where it is being stored as a string the console outputs:
SyntaxError: Unexpected token e in JSON at position 0
at JSON.parse (<anonymous>)
at Object.eval [as -MRLUTf0WkjK39M2CoSI//repeating_actives_-mrmiz2ltsxkbvvnyvpu//0.9079199319327471] (eval at messageHandler (sheetsandboxworker.js?1611688316695:698), <anonymous>:114:36)
at _fullfillAttrReq (sheetsandboxworker.js?1611688316695:673)
at messageHandler (sheetsandboxworker.js?1611688316695:705)
sheetsandboxworker.js?1611688316695:734 SyntaxError: Unexpected token e in JSON at position 0
at JSON.parse (<anonymous>)
at Object.eval [as -MRLUTf0WkjK39M2CoSI//repeating_actives_-mrmiz2ltsxkbvvnyvpu//0.9079199319327471] (eval at messageHandler (sheetsandboxworker.js?1611688316695:698), <anonymous>:114:36)
at _fullfillAttrReq (sheetsandboxworker.js?1611688316695:673)
at messageHandler (sheetsandboxworker.js?1611688316695:705)
when I change a rune value and trigger the sheetworker. In the ones where it stores properly the console outputs:
Foudn a pre-defined key order!
Yes, it says Foudn, not Found, no idea why.
Anyone have any idea what is going on?
Edit: sometimes the unexpected token is a "w" or an "o" or some other letter, but it seems to be consistent for each character.