what does it mean [Figwheel:SEVERE] java.lang.Exception: Don't know how to write JSON of class java.net.URL
just after it compiles a change to code ?
@octo221 that looks like it may be a serialization a bug in the code that sends messages to the client, there shouldn’t be a URL in there
I wonder why there is one
I'm using code-splitting if that helps
it correctly watches updates and recompiles, but i get that error when it tries to reload
oh wait I think I see now
I'm using websockets too
my websocket code could be interfering with Figwheel's
@octo221 if you are using 0.1.8-SNAPSHOT
and add :log-level :all
it should print out the stacktrace
If you could send that to me in an issue on figwheel-main that would be helpful
a minimal example would be very helpful so that I can see what the heck is going on
ok - where do I put :log-level :all
?
in the figwheel config, i.e metedata or figwheel-main.edn
i don't think my websocket code could interfere with Figwheel's actually
yeah it’s not likely, probably somehow a namespace is a url instead of a string and its getting passed to json
ok i started again, clearing my compile dir etc
now I get a different error: when I make code changes it compiles (I see the message in the REPL) and the client appears to recieve a message as there's a brief flash of a Figwheel notification, but the browser console says log: did not load (my.views my.ui my.module my.main)
there’s no stacktrace in the REPL?
no
i'm just going to go through everything again as I didn't really sleep last night
are you using the default dev host page?
no
and I have :open-url false
and you are aware that figwheel doesn’t load files that haven’t been required?
haven't been required
if a file isn’t in the require tree figwheel will not auto-reaload it untill it has been required
the file I'm modifying is in my program's require tree
OK cool just checking
it is required by the namespace of the main
for this module
and you are loading the module with a script tage on the host page
and your program loads and runs
I'm changing code for a module that's been dynamically loaded from another one previously
yeah that should work
what could be happening is that a warning is being thrown or an exception is being thrown and that is preventing the reload,
but the warning or exception is itself causing figwheel to throw
there's a brief flash of a red figwheel notification just before the console message
if there is a flash there should be a message in the console for the exception
oh not the 2dn time
yeh only the first time after the page loads and I change something
subsequently it only outputs the [Figwheel] did not load (
message
ok I tried without modules and I get the same thing
i managed to read the brief flash error message and it's the same as the console error
Figwheel is recompiling, because if I reload the page it's changed
it just doesn't reload it dynamically
there is a compile warning about a single segment namespace in one of the dependent libs
but that's just a warning
@octo221 OK so its the same error message as before the one about the Json URL thing?
no that error message has gone - now it only says [Figwheel] did not load (namespaces)
ok I cloned figwheel-core and overrode in my deps.edn to use the cloned local version and now I get the previous error
Figwheel:FINE] Detected changed cljs files: ("/my/ui/views.cljs")
[Figwheel] Compiling build dev to "public/js"
[Figwheel] Failed to compile build dev in 2.818 seconds.
[Figwheel] Compile Exception: Don't know how to write JSON of class java.net.URL
[Figwheel:SEVERE] java.lang.Exception: Don't know how to write JSON of class java.net.URL
[Figwheel:FINE] {:cause "Don't know how to write JSON of class java.net.URL",
:via
[{:type java.lang.Exception,
:message "Don't know how to write JSON of class java.net.URL",
:at [clojure.data.json$write_generic invokeStatic "json.clj" 385]}],
:trace
[[clojure.data.json$write_generic invokeStatic "json.clj" 385]
[clojure.data.json$write_generic invoke "json.clj" 382]
[clojure.data.json$fn__2717$G__2712__2724 invoke "json.clj" 286]
[clojure.data.json$write_object invokeStatic "json.clj" 335]
[clojure.data.json$write_object invoke "json.clj" 319]
[clojure.data.json$fn__2717$G__2712__2724 invoke "json.clj" 286]
[clojure.data.json$write_array invokeStatic "json.clj" 348]
[clojure.data.json$write_array invoke "json.clj" 342]
[clojure.data.json$fn__2717$G__2712__2724 invoke "json.clj" 286]
[clojure.data.json$write invokeStatic "json.clj" 475]
[clojure.data.json$write doInvoke "json.clj" 424]
[clojure.lang.RestFn invoke "RestFn.java" 425]
[clojure.lang.AFn applyToHelper "AFn.java" 156]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[clojure.core$apply invokeStatic "core.clj" 661]
[clojure.core$apply invoke "core.clj" 652]
[clojure.data.json$write_str invokeStatic "json.clj" 482]
[clojure.data.json$write_str doInvoke "json.clj" 477]
[clojure.lang.RestFn invoke "RestFn.java" 410]
[figwheel.core$compiler_warnings_code invokeStatic "core.cljc" 657]
[figwheel.core$compiler_warnings_code invoke "core.cljc" 655]
[figwheel.core$handle_warnings invokeStatic "core.cljc" 661]
[figwheel.core$handle_warnings invoke "core.cljc" 659]
[figwheel.core$start_STAR_$fn__4222 invoke "core.cljc" 781]
[clojure.lang.ARef notifyWatches "ARef.java" 81]
[clojure.lang.Atom swap "Atom.java" 83]
[clojure.core$swap_BANG_ invokeStatic "core.clj" 2347]
[clojure.core$swap_BANG_ doInvoke "core.clj" 2337]
[clojure.lang.RestFn invoke "RestFn.java" 497]
[figwheel.core$eval4238$build__4240 doInvoke "core.cljc" 841]
...
I get this error each time I edit this file, but it does compile because if I reload the page I see the changes
@octo221 This is fantastic. Now I know its data that’s in the warning. If you check out the latest figwheel-core and use it we should also see the actual data that is causing the error. I’m going to look at the warning data processing right now to see what the problem could be.
@octo221 there is a :load-warninged-code
option that will load the code even when warnings are detected and this may help in the short term? https://figwheel.org/config-options#load-warninged-code
I’m going to deploy some debugging code for this situation to figwheel-core 1.8.0-SNAPSHOT
OK I just deployed code to print out the error if its happening in figwheel
@octo221 if you make sure you are using getting the latest figwheel-core you should hopefully get a print out of the error
I have :mvn/version
"0.1.8-SNAPSHOT" for figwheel-core and main in my deps.edn
but I get the same results
I looked in figwheel-core's github repo for a SHA to point at but the last commit was 7 days ago
@octo221 I didn’t push the change to the repo
I just pushed the debugging code
@octo221 ok I just pushed a fix for this to figwheel-core, it should make the exception go away
hi, I've cloned figwheel-core & am using it locally in my deps.edn (figwheel-core's deps.edn needs a :paths
key)
I still get the error though
i checked I'm definitely using the local clone by changing the log message on line 304
sorry to be clear I still get the 'did not load' error not the JSON one
right - I've added ^:figwheel-load
to the namespace I'm changing (I'm change the colour of something), and I've added some debug messages to figwheel-core in reload-namespaces, and I see that after I make a change, namespaces
has 4 of my namespaces including the one I've changed, but to-reload
is empty
@octo221 OK so the JSON Error is no longer the problem and now we are having problems with reloading in general. I’m going to check out the reloading behavior for dynamically loaded modules
I really appreciate you reporting this so that I can get to the bottom of this
we’ve plugged one rare bug… let’s see if we can find the other one
ok I fixed a problem in a third-party lib that was causing a compilation warning about a single-segment namespace
and then I restarted figwheel main
now get this:
loading module my client core.cljs:192:16
log:Module loaded: cljs_base logger.js:367:5
[goog.module.ModuleManager] Module loaded: cljs_base console.js:203:5
log:Module loaded: client logger.js:367:5
[goog.module.ModuleManager] Module loaded: client console.js:203:5
> [my.ui.views my.ui.ui my.ui.module] core.cljs:192:16
> [my.ui.views my.ui.ui my.ui.module my.ui.main] core.cljs:192:16
log:loaded (my.ui.views my.ui.ui my.ui.module) logger.js:367:5
[Figwheel] loaded (my.ui.views my.ui.ui my.ui.module) console.js:203:5
log:really did not load (my.ui.main) logger.js:367:5
[Figwheel] really did not load (my.ui.main) console.js:203:5
- the > lines are to-reload and namespace respectivelyand, it actually does reload but I have to force it to update by interacting with the UI somehow
e.g. if I change the size of something normally with lein-figwheel it would update and I would see the result, but here it updates and I only see the result after I do something in the UI to make react update
on the same codebase?
meaning when you used this codebase with line-figwheel it updated as you would expect?
or is this a different codbase?
@octo221 you probably need a reload hook to touch your atom to force a rerender
yes with this codebase lein-figwheel works fine
yeah but you had a reload hook for lein-figwheel probably right?
:on-js-reload ?
ummm
oh let me check
and for figwheel-main you would use https://figwheel.org/docs/hot_reloading.html#reload-hooks
ahah yes in project.clj I had :before-jsload and :on-jsload
so go ahead and use the new reloading mechanism and you should be good
and here’s a reminder to use https://figwheel.org/config-options#load-warninged-code
when you have a warning that is preventing reloads
and it works!
got it - thank you so much for all your help!
i completely forgot about :on-load
when I switched to deps.edn
I’m now going to check the reloading is working correctly for code-splitting
but also make sure you have read https://figwheel.org/docs/hot_reloading.html#force-a-file-to-be-loaded
I added ^:figwheel-load
to the namespaces I'm changing but no change
as it will help you in your current circumstance hopefully