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

Troubleshooting API scripts

I have an API script that has an error in it, and i don't know which one it is. I probably just go by the last scripts i added and start turning them off one by one, but is there a faster method? I have this from the API console screen from when the sandbox crashed: TypeError: Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined at handleToken (apiscript.js:10959:44) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:911:16) at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) at /home/node/d20-api-server/api.js:1378:11 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Rd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) Any way of figuring out which one is the culprit from this? Thanks!
1511382384
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
What scripts do you have installed?
Scott C. said: What scripts do you have installed? Here is a screenie:
1511389081

Edited 1511389107
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ok, well your error is being thrown by a function called tokenHandler. I'm not sure which script it is from.  But based on the function name, and likely purpose, It's probably either It's a Trap or Torch. What were you doing when the error was generated?
hmm if anything, i was probably messing around with tokens and assigning them to new character sheets. But i can't remember exactly what i was doing because i didn't notice it right away. I'll try disabling torch since i don't even use it and see what happens.  Thanks! 
1511476940
The Aaron
Pro
API Scripter
It's in AuraHealth / HealthColors.  My guess is it's looking for a customfx that is missing.  Line 101 or 109 is the only place it's referencing .get() on an object that might be undefined.
oh yeah?  How are you guys able to track which script is causing the issues when i see something like this? is it just going through each API script i have?
1511496584

Edited 1511496634
The Aaron
Pro
API Scripter
In my case, I went in the directory I have all the Roll20 scripts checked out in and ran: ag “\bhandleToken\b” which recursively searches all the files for the phrase “handleToken” with word boundaries at either end. Only AuraHealth has matches.  Then I searched that function for all \.get\> which in my editor is all the .get() calls. Then examined each one for code paths that could lead to executing it on an undefined object. 
Since I want to use Aura/Health as well, is there any thing you can think of that would help it work better?
1511575004
The Aaron
Pro
API Scripter
Usually it just works. :). I’m speculating that it creates Jukebox entries that it assumes exist, and the got removed. 
yeah it seems a bit flacky. it "DOES" just work, but i noticed when i'm moving stuff around ( ala toke creation, or transmorgifying) if i put a token on the table and i havent set perms yet, it bugs out.