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

Events don't cascade properly in sheet:opened

1458408660

Edited 1458409143
Lucian
Pro
API Scripter
If you call setAttrs in a 'sheet:opened' handler in a sheetworker script, it generally doesn't generate the proper change events for attributes that are updated, so dependent sheet workers don't get called. I have verified this by putting logging into the trigger method in sheetsandboxworker.js - usually I get no events firing at all from changes that I make in setAttrs. This is a Heisenbug that goes away if you step through the code in the debugger - presumably because the problem is a race condition of some sort. It would seem the either sheet:opened needs to not be fired until the rest of the system is ready for it, or setAttrs calls from it need to be queued somewhere until the relevant code is ready so that events get generated properly. I suspect that this behaviour varies depending on server load/connection speed/random neutrino activity, so it's not always predictable, but hopefully now I've identified it (after a *very* frustrating afternoon!) it shouldn't be too hard to track down. Given that the API can't trigger sheetWorkers, being able to take substantial action in sheet:opened is actually pretty essential - we're using it to populate the 5e shaped sheet from import data built by the API - so I'd say this is actually quite a high priority problem.
1460049461
Stephen Koontz
Forum Champion
Marketplace Creator
Sheet Author
API Scripter
Compendium Curator
We pushed out a possible fix for this issue today. Let us know if you're still having this problem.
1460049642
Lucian
Pro
API Scripter
Ok, thanks - we now have a slightly different solution to dealing with the import so we're not firing as much stuff in sheet:opened any more, so this happens less than it used to anyway, but I will do some testing and see if it looks better
1460105334
Lucian
Pro
API Scripter
Hi Steve, I've had a quick go with this and I'm seeing all the events I was expecting now - hopefully that's not just the stars happening to align for me today but actually a successful fix! I'll let you know if I see any recurrence.  Thanks for the quick turn around - much appreciated! Lucian