Fork me on GitHub
#figwheel
<
2020-06-03
>
lwhorton18:06:11

i might be misconfiguring figwheel, but if i turn off chrome > security > allow third party site cookies, figwheel vomits on load with a `DOMException: Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.`. you … cant really use figwheel with this option disabled, but is there a way to at least have figwheel check property access in a try/catch without just throwing outright? maybe a `:preloads` namespace that overrides the window.local/sessionStorage options first-thing, then more gracefully handles those security access errors?

bhauman18:06:25

@lwhorton yeah this should probably be a try/catch. This is in #figwheel-main right? I’ll definitely take a PR if you’re into it.

bhauman18:06:46

I’ll be doing a release soon

lwhorton19:06:29

ill see what i can do this afternoon

lwhorton20:06:49

scratch that, no way i’ll be able to get anything submitted since this is a pretty low-prio issue on our end. definitely dont anticipate a PR. 😞 i’m a bad OSS contributor.

lwhorton20:06:52

i would think maybe this does it? but i haven’t setup checkouts and dont know the workings of sidecar/plugin, etc. to test this out locally:

+++ b/support/src/figwheel/client/utils.clj
@@ -21,5 +21,7 @@

 (defmacro feature?
   [obj feature]
-  `(and (cljs.core/exists? ~obj)
-        (cljs.core/exists? (goog.object/get ~obj ~feature))))
+  `(try
+     (and (cljs.core/exists? ~obj)
+          (cljs.core/exists? (goog.object/get ~obj ~feature)))
+     (catch :default _ false)))

lwhorton20:06:41

:default might not work in JS, it might have to be a js/DOMException

bhauman21:06:14

that relies on the feature not existing

bhauman21:06:45

does it actually not exist? or is there only a problem when you access it?

lwhorton21:06:18

if i turn on the chrome feature ‘block sites from setting …’ described here https://stackoverflow.com/questions/30481516/iframe-in-chrome-error-failed-to-read-localstorage-from-window-access-deni it looks like (for chrome at least) whenever you attempt to even read that property (. js/Window -localStorage) (or sessionStorage) with that feature blocked, you get this error:

lwhorton21:06:22

Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

lwhorton21:06:53

don’t let my code mislead you, though. i only had about 30m to poke around in the codebase so there’s a very good chance this is not at all in the right place. sorry 😞

lwhorton21:06:55

also, fwiw… i dont think most webapps have supported disabling cookies in this manner since like 2008 🤷

lwhorton21:06:49

> or is there only a problem when you access it this ^