shinyworks / cookies

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

shinyapp.ts:437 TypeError: Cannot read properties of null (reading 'readyState') #67

Closed mbjohnsonmn closed 1 year ago

mbjohnsonmn commented 1 year ago

Hi Jon. I've spent a long time trying to isolate this error. It appeared last Friday (9/1) without any changes to my code. I've narrowed it down to section that loops through a set of 'get_cookie' calls - nine to be exact. In the R console, I get, "Warning: Error in if: argument of length zero." Not much help. Here is the text of the full error in the browser:

shinyapp.ts:437 TypeError: Cannot read properties of null (reading 'readyState') at e.value (shinyapp.ts:584:25) at e.value (shinyapp.ts:459:12) at e.value (inputBatchSender.ts:65:23) at inputBatchSender.ts:47:19 at e. (shinyapp.ts:430:22) at v (shinyapp.ts:5:1357) at Generator. (shinyapp.ts:5:4174) at Generator.next (shinyapp.ts:5:2208) at F_ (shinyapp.ts:6:99) at u (shinyapp.ts:7:194)

Again, not much help for me, but a comment/solution to a similar post in SO that mentions typos in JS code I recall you mentioning that you may be doing some work there?

I also noticed that the sample app in the documentation no longer works. It throws this error: Warning: Error in set_cookie: ✖ Cannot update cookie selected_number. ℹ HttpOnly cookies can only be updated via set_cookie_response().

As always, thanks for your great work on the package.

Morris

jonthegeek commented 1 year ago

@mbjohnsonmn Have you installed the dev version of the package? Try it out if not. It isn't a final fix, but it fixes the sample app issue.

# install.packages("remotes")
remotes::install_github("r4ds/cookies")

I think something changed in Shiny timing that broke {cookies}. I'm hoping to find time to dig deep into this package again in a few weeks, HOPEFULLY I can implement a more stable fix then.

Let me know whether the dev version helps!

mbjohnsonmn commented 1 year ago

@jonthegeek Thanks for the quick reply! No joy I am afraid, but thank you for trying.

This is a really hard one since I starting experiencing the same error behavior on two somewhat independent versions: one hosted on shinyapps.io and one a remote shiny server on a local Linux installation. And on localhost, of course. I think your hypothesis of a change in shiny or one of the other JS dependencies makes sense. A great learning opportunity, if nothing else!

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!