Roll20 / roll20-api-scripts

API Scripts created by the community for use in Roll20 VTT. Submit a ticket at roll20.net/help if critical hotfixes are to be requested.
https://roll20.net/
MIT License
388 stars 567 forks source link

Cannot one click install script COFantasy #884

Closed Ulty closed 3 years ago

Ulty commented 4 years ago

When trying to one-click install the COFantasy script, the API crashes with error message:

SyntaxError: Invalid or unexpected token

When importing (using the "Import" button, instead of "Add script" button) everything works just fine.

ChrisDDickey commented 4 years ago

I had the same problem with my scripts. See https://app.roll20.net/forum/post/8008726/slug%7D I am not 100% certain which of the things I tried actually fixed it, but I think it was ether changing my text editors encoding from UTF-8 BOM to UTF-8. Or it might have been rewriting my code to not store any of the extended character sets characters as literals. In any case, there is something somewhere that Roll20 itself does not object to, but that the one-click library does object to. Check your encoding, check for weird characters, and submit the script again, and the problem might just go away.

shdwjk commented 4 years ago

It was a UTF-8 BOM marker. I pushed a fix for this a month or so ago.

ChrisDDickey commented 4 years ago

If a fix has been done, I think you can request this issue be closed.

Ulty commented 4 years ago

@ChrisDDickey : Thanks for pointing that out. It is good to know that it's not the only script!

@shdwjk : I hadn't noticed your push, sorry. Unfortunately, you only corrected the doc (which shouldn't impact the one-click install, should it?), and that only for version 0.1, so the issue is still there. Did you just not find any UTF8-BOM in the other files? I couldn't find any such instance myself, but I may have missed it?

Ulty commented 4 years ago

One additional point: the one-click install for the script used to work fine, until half a year ago. But the older versions (0.1 to 1.6), which have not changed, do not work anymore. So something changed on the Roll20 side...

Far2Casual commented 4 years ago

6 months, and still no idea what is happening ? Could anyone help us debug the issue ?

Anduh commented 4 years ago

@wing-it any comments?

clevett commented 4 years ago

I looked into this a few months ago. The issue is a syntax error in the script. I started taking out functions and was able to get it to work in the one-click however the script is so long that I wasn't able to find which function/s were an issue. You might try running it through a Javascript linter to see if there are any issues to fix and ensure the encoding is correct as mentioned above.

Ulty commented 4 years ago

Hi @clevett . I did try jshint, and @Far2Casual passed esprima and jslint. Also, I would think that the best validator would be copy-pasting the code into the API sandbox, no? The fact that copy-paste and import work fine, without even an error message, suggests to me 3 possibilities:

On my side, there is not much left I can do. Maybe you could suggest a better validator than jshint, esprima or jslint? Or we could add a copy of the script to the git, so that I could bisect the issue? That would be awfully slow, but at least I could do something. Best would be if we could have more detailed syntax error messages: maybe the development team could give it a try with more verbose parser settings? Maybe there are other possible reasons for the issue I haven't thought of?

Far2Casual commented 4 years ago

@Anduh @clevett As explained by @Ulty above we tried to track down simple syntax errors in the script using multiple JS linters, for no results. I believe that if there was such thing as a "simple" Syntax Error, the code would never work. But it does work, when you c/p the code directly or you use the "Import" button in roll20. I have multiple working games with the script. The script only specifically crashes when you use the "Add" button on roll20 to add it to your game. We suspect that it comes from some sort of code parsing or transformation that only specifically happen when that button is used. Maybe there is something in our code that's not compatible with that, but we have no way to investigate that.

Anduh commented 4 years ago

Did the recent updates to the script fix this?

Ulty commented 4 years ago

No, they didn't, unfortunately.

Ulty commented 3 years ago

Issue is still open. No answer from the ticket I opened. Could the size of the script be an issue?

clevett commented 3 years ago

Last fall when I still worked for Roll20, I had started trouble shooting this on a local dev env by removing virtually all the code and piece by piece adding functions back to try to find where the error was. I threw in the towel after a few hours due to the sheer size of the script.

There is something in the script's JS that the Roll20 code doesn't approve of. Size is a possibility. I don't think there is a way for you to troubleshoot it since manually adding the script shows no errors.

Sorry this post isn't more helpful. I just wanted to share my experience of trying resolve this issue.

Ulty commented 3 years ago

Thank you Cassie. Too bad this is not on your hands, anymore. I suppose I have to wait until one day the issue gets accidentally solved, or just look for another platform.

clevett commented 3 years ago

If you really want to solve the issue, your best option is to break this script down into multiple smaller scripts. This probably wouldn't be the best user experience and it would be a lot of work.

Ulty commented 3 years ago

What I find the most surprising is that older versions of the script, that used to work just fine (could be installed using 'Add') do not work anymore. Even the first version of the script, which was only 8800 lines long, cannot be added anymore.

wing-it commented 3 years ago

Can you please confirm this is still broken? I'm able to add this to a game with no problem.

Ulty commented 3 years ago

I just tried it and it worked! I hope it is due to some internal fix by Roll20, because if that is a change in my code, I have no idea what the issue was...

Far2Casual commented 3 years ago

Woohoo !

Anduh commented 3 years ago

I hope it is due to some internal fix by Roll20

well, wing-it is doing coding stuff for roll20, so don't think he'd ask about this unless they applied a fix first.

wing-it commented 3 years ago

Actually, I had done some other work on the API before getting to this ticket. Was already fixed when I got to it, so I guess some of my previous work ended up fixing this unintentionally (as much as I would like to take credit).

Anduh commented 3 years ago

lol

Ulty commented 3 years ago

The script can now be installed through the 'Add' button, but when installed this way, all accented characters are replaced by series of question marks. Accented characters are displayed normally whein using the 'Import' button.

Ulty commented 3 years ago

I believe the issue lies in the transformation of accented characters, somewhere in Roll20 chain when they add it to the game. It shouldn't be too hard to figure out which one it is, as accents are preserved with the 'Import' button, and no with the 'Add' button. Anyway, I have a work-around, so I close this issue.