shinyworks / cookies

Use Browser Cookies with 'shiny'
https://shinyworks.github.io/cookies/
Other
32 stars 4 forks source link

"Shiny.setInputValue is not a function" on load #66

Closed avsdev-cw closed 1 year ago

avsdev-cw commented 1 year ago

It looks like the library is registering before Shiny loads (we have some quite large applications).

Traceback says the culprit is this listener:

window.addEventListener('focus', function() {
  getCookies();
});

I've tried both devel and released (0.2.2) versions

jonthegeek commented 1 year ago

Thanks for the report! I'll look into it as soon as I can. We have some other racetime issues with Shiny, so I suspect a general hardening in that area will make a lot of things simpler.

avsdev-cw commented 1 year ago

I've also noticed that this commit: Temporarily deal with over-zealous http-only check. seems to prevent the cookies from initially loading (at least before the full "input" system is loaded).

Probably Because of the removal of line 138.

https://github.com/r4ds/cookies/commit/555923505b93168ced81bdcbd23e6cd7eba36ea3#diff-9e95b340633529fb09e594e8e485b849dac8a3aa0d81017be4c7556d34bfb05bL138

jonthegeek commented 1 year ago

I think this will fix your issues. Please let me know if it doesn't! I'm submitting this to CRAN in any case to fix a breaking issue in the tests, but hopefully it's a real fix!