Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

API Error in Sandbox

Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: Error: Firebase.update failed: First argument contains NaN in property 'current' Error: Firebase.update failed: First argument contains NaN in property 'current' at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:9:186) at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:207) at Aa (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:8:462) at Ea (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:403) at J.update (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:146:318) at TrackedObj._doSave (/home/node/d20-api-server/api.js:766:27) at Timeout.later [as _onTimeout] (/home/node/d20-api-server/node_modules/underscore/underscore.js:828:25) at ontimeout (timers.js:380:14) at tryOnTimeout (timers.js:244:5) at Timer.listOnTimeout (timers.js:214:5) Any ideas?  I have been getting this error for about two days.  I don't have the slightest idea what it means.
Without knowing what scripts you're using, it's nigh impossible to tell what your problem is, but I can take a guess that one of your attributes on a token or character is not a number (NaN) and one of your scripts is looking for a number and failed without catching that error. Disable all your api scripts and restart them one at a time until you get that error again and you'll know which script is the problem.
1493121241
The Aaron
Pro
API Scripter
Slight refinement on what HB (Sky) said:  One of the scripts you have just updated an Attribute's current property, but whatever it tried to put in it evaluated to NaN.  Firebase does not accept NaN as a value and throws that exception when it tries to persist the API script's change into the Firebase storage for that game.   If you have a list of the scripts you have installed, we might be able to infer which ones are likely to have caused the issue.
I have found that I most often get this error when I use the parseInt function for a value that does not meet the requirements of parseInt. For example "text1" would result in NaN whereas "1text" would result in 1. If you use parseInt and you don't know if the text you are passing will match you could do parseInt(variableName||0) which will default the result to 0 unless it can parse the first value.
1493121788

Edited 1493121935
The Aaron
Pro
API Scripter
Actually: parseInt(variableName,10) || 0 Non-zero length text is truthy, so putting the || inside the call will only catch empty text. You're right, that is the most common way to get NaN.
I used the XP script and put a bad syntax in and it returned a value of NaN in the chat, but the scripts were shutting down before I ever tried that.  I kept restarting it during my game last night and they would shut down within a few minutes.  Then towards the end I did the XP thing and it was working so I tried adding XP to one character with !xp challenge @{selected|token_id} and that's where the NaN thing came from.  I do not remember what the script error messages were before that as I didn't pay much attention. I am running all of these: Script Library G Ammo G EasyExperience G GroupCheck G GroupInitiative G Status FX G Torch G Roll20 Audio Master G splitArgs G Custom FX G Page FX G Vector Math G MatrixMath G Path Math G Token Collisions G HTML Builder G It's a Trap! G It's a Trap! - D&D 5E Shaped theme G Aura/Tint HealthColors G Areas of Effect G TokenMod G TokenNameNumber Measure 5eShapedCompanion alterbars Aarons Doors New Script Plus, I noticed this message in chat as well: "(From ItsATrap-5E-Shaped): This script is deprecated. Please use the generic D&D 5E trap theme instead." That's new. This is what my current sandbox says: "Spinning up new sandbox... "Starting webworker script..." "Loading 905 translation strings to worker..." "It's A Trap!: Registered TrapTheme - default." "-=> Ammo v0.3.7 <=- [Fri Mar 24 2017 13:39:53 GMT+0000 (UTC)]" "-=> EasyExperience v1.1 <=- [Fri Oct 07 2016 21:41:37 GMT+0000 (UTC)]" "-=> GroupCheck v1.3.1 <=-" "-=> GroupInitiative v0.9.25 <=- [Tue Mar 14 2017 13:11:07 GMT+0000 (UTC)]" "StatusFX: red -> splatter-blood [1,-1]" "StatusFX: green -> bubbling-acid" "StatusFX: sleep -> glow-holy" "StatusFX: stars -> beam-fire [2,3]" "-=> Torch v0.8.11 <=- [Thu Mar 30 2017 10:50:46 GMT+0000 (UTC)]" "-=> Roll20AM v1.05 <=- [Wed Apr 05 2017 00:26:44 GMT+0000 (UTC)]" " > Updating Schema to v1.05 <" " >Stored settings loaded<" " >Tracks updated<" " >Help handout updated<" "-=>HealthColors v1.5.1 [Updated: April 6 2017]<=-" "--- Initialized Areas Of Effect v1.3 ---" "-=> TokenMod v0.8.34 <=- [Thu Apr 13 2017 21:05:10 GMT+0000 (UTC)]" "-=> TokenNameNumber v0.5.10 <=- [Thu Mar 30 2017 10:49:49 GMT+0000 (UTC)]" "-=> Measure v0.3.2 <=- [Thu Mar 30 2017 10:34:06 GMT+0000 (UTC)]" "5eShapedCompanion 1493129680895 INFO : Summary of adding SRD entity group to the lookup: {\"errors\":0,\"entityGroupName\":{},\"classes\":{\"withErrors\":0,\"deleted\":0,\"patched\":0,\"added\":8},\"monsters\":{\"withErrors\":0,\"deleted\":0,\"patched\":0,\"added\":325},\"spells\":{\"withErrors\":0,\"deleted\":0,\"patched\":0,\"added\":319}}" "5eShapedCompanion 1493129680897 INFO : -=> ShapedScripts v8.4.2 <=-" "ERROR: You cannot set the imgsrc or avatar of an object unless you use an image that is in your Roll20 Library. See the API documentation for more info." "-=> AlterBars v2.0.4 <=- [Tue Mar 21 2017 12:38:05 GMT+0000 (UTC)]" "☒☠☒ Initialized It's A Trap! using theme 'default' ☒☠☒" "5eShapedCompanion 1493129683295 INFO : Detected sheet version as : 11.3.3" "5eShapedCompanion 1493129683297 INFO : Configuration state: {\"version\":4.6,\"config\":{\"genderPronouns\":[{\"matchPattern\":\"^f$|female|girl|woman|feminine\",\"nominative\":\"she\",\"accusative\":\"her\",\"possessive\":\"her\",\"reflexive\":\"herself\"},{\"matchPattern\":\"^m$|male|boy|man|masculine\",\"nominative\":\"he\",\"accusative\":\"him\",\"possessive\":\"his\",\"reflexive\":\"himself\"},{\"matchPattern\":\"^n$|neuter|none|construct|thing|object\",\"nominative\":\"it\",\"accusative\":\"it\",\"possessive\":\"its\",\"reflexive\":\"itself\"}],\"logLevel\":\"INFO\",\"tokenSettings\":{\"number\":true,\"bar1\":{\"attribute\":\"AC\",\"max\":false,\"link\":false,\"showPlayers\":false},\"bar2\":{\"attribute\":\"\",\"max\":false,\"link\":false,\"showPlayers\":false},\"bar3\":{\"attribute\":\"HP\",\"max\":true,\"link\":false,\"showPlayers\":false},\"aura1\":{\"radius\":\"\",\"color\":\"#FFFF99\",\"square\":false},\"aura2\":{\"radius\":\"\",\"color\":\"#59e594\",\"square\":false},\"light\":{\"radius\":\"\",\"dimRadius\":\"\",\"otherPlayers\":false,\"hasSight\":true,\"angle\":360,\"losAngle\":360,\"multiplier\":1},\"showName\":true,\"showNameToPlayers\":true,\"showAura1ToPlayers\":true,\"showAura2ToPlayers\":true,\"monsterTokenName\":\"\"},\"newCharSettings\":{\"sheetOutput\":\"***default***\",\"deathSaveOutput\":\"***default***\",\"initiativeOutput\":\"\",\"showNameOnRollTemplate\":\"{{show_character_name=1}}\",\"rollOptions\":\"1d20\",\"initiativeRoll\":\"***default***\",\"initiativeToTracker\":\"***default***\",\"breakInitiativeTies\":true,\"showTargetAC\":true,\"showTargetName\":true,\"autoAmmo\":true,\"autoRevertAdvantage\":false,\"houserules\":{\"mediumArmorMaxDex\":0,\"saves\":{\"useCustomSaves\":false,\"useAverageOfAbilities\":false,\"fortitude\":{\"fortitudeStrength\":false,\"fortitudeDexterity\":false,\"fortitudeConstitution\":false,\"fortitudeIntelligence\":false,\"fortitudeWisdom\":false,\"fortitudeCharisma\":false},\"reflex\":{\"reflexStrength\":false,\"reflexDexterity\":false,\"reflexConstitution\":false,\"reflexIntelligence\":false,\"reflexWisdom\":false,\"reflexCharisma\":false},\"will\":{\"willStrength\":false,\"willDexterity\":false,\"willConstitution\":false,\"willIntelligence\":false,\"willWisdom\":false,\"willCharisma\":false},\"savingThrowsHalfProf\":false},\"baseDC\":\"***default***\",\"expertiseAsAdvantage\":false,\"inspirationMultiple\":false,\"criticalDamageHouserule\":\"CRITICAL_DAMAGE_IS_MAXIMIZED\",\"proficiencyDice\":false,\"psionics\":true,\"customClasses\":true,\"honorToggle\":false,\"sanityToggle\":true,\"hitPointsRecoveredOnALongRest\":\"***default***\",\"hitDiceRecoveredOnALongRest\":\"***default***\"},\"tab\":\"***default***\",\"tokenActions\":{\"initiative\":true,\"abilityChecks\":\"abilChecks\",\"advantageTracker\":null,\"savingThrows\":\"saves\",\"attacks\":\"attacks\",\"statblock\":true,\"traits\":\"traitsMacro\",\"actions\":\"actionsMacro\",\"reactions\":\"reactionsMacro\",\"legendaryActions\":null,\"lairActions\":null,\"regionalEffects\":null,\"rests\":true,\"spells\":true,\"showRecharges\":true,\"classFeatures\":\"classFeaturesMacro\",\"feats\":\"featsMacro\",\"racialTraits\":\"racialTraitsMacro\"},\"textSizes\":{\"spellsTextSize\":\"***default***\",\"abilityChecksTextSize\":\"***default***\",\"savingThrowsTextSize\":\"***default***\"},\"hide\":{\"hideAttack\":\"***default***\",\"hideDamage\":\"***default***\",\"hideAbilityChecks\":\"***default***\",\"hideSavingThrows\":\"***default***\",\"hideSavingThrowDC\":\"***default***\",\"hideSavingThrowFailure\":\"***default***\",\"hideRecharge\":\"***default***\",\"hideFreetext\":\"***default***\",\"hideContent\":\"***default***\"},\"applyToAll\":true,\"hitDiceOutput\":\"***default***\",\"display\":{\"showPassiveSkills\":true,\"showWeight\":\"***default***\",\"showEmote\":true,\"showFreetext\":true,\"showFreeform\":true,\"showDiceModifiers\":false,\"showCritRange\":true,\"extraOnACrit\":true},\"measurementSystems\":{\"distanceSystem\":\"***default***\",\"weightSystem\":\"***default***\"},\"automaticHigherLevelQueries\":\"***default***\",\"automaticallyExpendSpellResources\":true,\"automaticallyRollDamageForAttacks\":\"***default***\",\"automaticallyRollDamageForSavingThrows\":\"***default***\"},\"advTrackerSettings\":{\"showMarkers\":true,\"ignoreNpcs\":false,\"advantageMarker\":\"green\",\"disadvantageMarker\":\"red\",\"output\":\"public\"},\"sheetEnhancements\":{\"rollHPOnDrop\":true,\"autoHD\":true,\"autoTraits\":true,\"turnRecharges\":false,\"ammoRecovery\":true},\"defaultGenderIndex\":2,\"variants\":{\"rests\":{\"longRestHDRecovery\":0.5,\"longRestHPRecovery\":1}},\"playerId\":\"-KgBXmc9q4oKK_Jh3DCB\"},\"ammoTracking\":{}}"
1493129965
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, gonna have to put in gating to stop that NaN from happening. Adding it to my EasyExperience todo list.
1493135079

Edited 1493135168
Ada L.
Marketplace Creator
Sheet Author
API Scripter
The 5E Shaped trap theme's script is deprecated but it's functionality still exists with the new 5E Generic trap theme. Install the 5E Generic trap theme and on its script options page, set the "sheet" option to "shaped" and that should work fine again.
1493143032

Edited 1493143120
Lithl
Pro
Sheet Author
API Scripter
The Aaron said: Actually: parseInt(variableName,10) || 0 Non-zero length text is truthy, so putting the || inside the call will only catch empty text. You're right, that is the most common way to get NaN. NaN also comes from Math functions failing (eg, Math.sqrt(-1) ). Invalid mathematical operations also produce NaN (eg, 'foo' / 100 ). Really, it's anything that ought to be a number and isn't. Hence Not a Number. =) Or, since NaN !== NaN , you might say it's Not a NaN. ~_^