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

ReferenceError: console not defined

1461227770

Edited 1461227849
Hello! I am trying to make my script more robust and now I encountered a strange error. For reference, the error message generated was: ReferenceError: console is not defined at apiscript.js:7957:6 at checkFinishedOps (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:758:7) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:838:8) at null._onTimeout (/home/node/d20-api-server/node_modules/underscore/underscore.js:768:19) at Timer.listOnTimeout (timers.js:92:15) This error usually occurs when someone uses console.log() like in the Sheet Workers instead of just log() like in the API. Now the strange thing: I don't use the keyword "console" anywhere (which is easily testable by simply searching for the string). I am aware that the script is not very robust yet and I really don't wan't you guys to do the debug work for me, but just as with the missing error message in the last thread I want to help to find those (minor) bugs as it makes debugging for us way easier. I believe that roll20 somewhere tries to call console.log() instead of log() as I am not using the keyword myself. Campaign 647721 Steps to reproduce: Open character "Basismensch" and go to the character sheet Go to main tab "Magie", go to subtab "Alchemy" Click on some of the buttons under the long list of "Zauber" and enter a value of 2 or 3 in the popup. This just ensures that the script will create entries under "Präparate" for you. Once an entry under "Präparate" was created click like crazy on the last button of the entry under "total". The script engine will crash with the above error.
1461257044
Phil B.
Forum Champion
Sheet Author
For debugging you will want to use just "log", instead of "console.log". Since the API runs using a JS worker in a sandbox it does not have access to the normal browser objects. Using "log" will work the exact same way, only it will print to the API console rather than your browser console.
1461273154

Edited 1461274270
I know This error usually occurs when someone uses console.log() like in the Sheet Workers instead of just log() like in the API. I don't use the keyword "console" anywhere (which is easily testable by simply searching for the string). [...] I believe that roll20 somewhere tries to call console.log() instead of log() as I am not using the keyword myself. I will have to do some further testing going step by step through all of the 3rd party scripts, but especially the one-click install scripts are difficult to test as all I can do there is to enable/disable them. This will take some time. The called script in the above procedure does not contain the string "console" at all in the whole file.
1461341286
Phil B.
Forum Champion
Sheet Author
You can always grab the script from the script repo (<a href="https://github.com/Roll20/roll20-api-scripts" rel="nofollow">https://github.com/Roll20/roll20-api-scripts</a>), if you're looking to dig around. The one-click install will be using the most recent version by default, so it should be pretty easy to find the one you are looking for.
Thank you!