Fork me on GitHub
#lein-figwheel
<
2018-08-20
>
octahedrion08:08:32

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 ?

bhauman13:08:50

@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

bhauman13:08:07

I wonder why there is one

octahedrion13:08:22

I'm using code-splitting if that helps

octahedrion13:08:49

it correctly watches updates and recompiles, but i get that error when it tries to reload

octahedrion13:08:05

oh wait I think I see now

octahedrion13:08:13

I'm using websockets too

octahedrion13:08:37

my websocket code could be interfering with Figwheel's

bhauman13:08:54

@octo221 if you are using 0.1.8-SNAPSHOT and add :log-level :all it should print out the stacktrace

bhauman13:08:36

If you could send that to me in an issue on figwheel-main that would be helpful

bhauman13:08:06

a minimal example would be very helpful so that I can see what the heck is going on

octahedrion13:08:23

ok - where do I put :log-level :all ?

bhauman13:08:01

in the figwheel config, i.e metedata or figwheel-main.edn

octahedrion14:08:57

i don't think my websocket code could interfere with Figwheel's actually

bhauman14:08:11

yeah it’s not likely, probably somehow a namespace is a url instead of a string and its getting passed to json

octahedrion14:08:02

ok i started again, clearing my compile dir etc

octahedrion14:08:19

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)

bhauman14:08:25

there’s no stacktrace in the REPL?

octahedrion14:08:27

i'm just going to go through everything again as I didn't really sleep last night

bhauman14:08:27

are you using the default dev host page?

octahedrion14:08:55

and I have :open-url false

bhauman14:08:13

and you are aware that figwheel doesn’t load files that haven’t been required?

octahedrion14:08:33

haven't been required

bhauman14:08:30

if a file isn’t in the require tree figwheel will not auto-reaload it untill it has been required

octahedrion14:08:02

the file I'm modifying is in my program's require tree

bhauman14:08:11

OK cool just checking

octahedrion14:08:17

it is required by the namespace of the main

octahedrion14:08:22

for this module

bhauman14:08:21

and you are loading the module with a script tage on the host page

bhauman14:08:38

and your program loads and runs

octahedrion14:08:41

I'm changing code for a module that's been dynamically loaded from another one previously

bhauman14:08:55

yeah that should work

bhauman14:08:49

what could be happening is that a warning is being thrown or an exception is being thrown and that is preventing the reload,

bhauman14:08:06

but the warning or exception is itself causing figwheel to throw

octahedrion14:08:23

there's a brief flash of a red figwheel notification just before the console message

bhauman14:08:54

if there is a flash there should be a message in the console for the exception

octahedrion14:08:55

oh not the 2dn time

octahedrion14:08:40

yeh only the first time after the page loads and I change something

octahedrion14:08:11

subsequently it only outputs the [Figwheel] did not load ( message

octahedrion15:08:18

ok I tried without modules and I get the same thing

octahedrion15:08:40

i managed to read the brief flash error message and it's the same as the console error

octahedrion15:08:59

Figwheel is recompiling, because if I reload the page it's changed

octahedrion15:08:18

it just doesn't reload it dynamically

octahedrion15:08:01

there is a compile warning about a single segment namespace in one of the dependent libs

octahedrion15:08:10

but that's just a warning

bhauman20:08:46

@octo221 OK so its the same error message as before the one about the Json URL thing?

octahedrion07:08:15

no that error message has gone - now it only says [Figwheel] did not load (namespaces)

octahedrion08:08:34

ok I cloned figwheel-core and overrode in my deps.edn to use the cloned local version and now I get the previous error

octahedrion09:08:16

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]
 ...

octahedrion09:08:33

I get this error each time I edit this file, but it does compile because if I reload the page I see the changes

bhauman12:08:40

@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.

bhauman12:08:43

@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

bhauman20:08:06

I’m going to deploy some debugging code for this situation to figwheel-core 1.8.0-SNAPSHOT

bhauman20:08:35

OK I just deployed code to print out the error if its happening in figwheel

bhauman20:08:34

@octo221 if you make sure you are using getting the latest figwheel-core you should hopefully get a print out of the error

octahedrion07:08:40

I have :mvn/version "0.1.8-SNAPSHOT" for figwheel-core and main in my deps.edn

octahedrion07:08:07

but I get the same results

octahedrion07:08:04

I looked in figwheel-core's github repo for a SHA to point at but the last commit was 7 days ago

bhauman12:08:04

@octo221 I didn’t push the change to the repo

bhauman12:08:02

I just pushed the debugging code

bhauman13:08:05

@octo221 ok I just pushed a fix for this to figwheel-core, it should make the exception go away

octahedrion13:08:00

hi, I've cloned figwheel-core & am using it locally in my deps.edn (figwheel-core's deps.edn needs a :paths key)

octahedrion15:08:03

I still get the error though

octahedrion15:08:54

i checked I'm definitely using the local clone by changing the log message on line 304

octahedrion15:08:20

sorry to be clear I still get the 'did not load' error not the JSON one

octahedrion15:08:52

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

bhauman17:08:41

@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

bhauman17:08:05

I really appreciate you reporting this so that I can get to the bottom of this

bhauman17:08:41

we’ve plugged one rare bug… let’s see if we can find the other one

octahedrion18:08:10

ok I fixed a problem in a third-party lib that was causing a compilation warning about a single-segment namespace

octahedrion18:08:20

and then I restarted figwheel main

octahedrion18:08:29

now get this:

octahedrion18:08:31

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 respectively

octahedrion18:08:44

and, it actually does reload but I have to force it to update by interacting with the UI somehow

octahedrion18:08:14

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

bhauman18:08:44

on the same codebase?

bhauman18:08:15

meaning when you used this codebase with line-figwheel it updated as you would expect?

bhauman18:08:28

or is this a different codbase?

bhauman18:08:37

@octo221 you probably need a reload hook to touch your atom to force a rerender

octahedrion18:08:06

yes with this codebase lein-figwheel works fine

bhauman18:08:43

yeah but you had a reload hook for lein-figwheel probably right?

bhauman18:08:59

:on-js-reload ?

octahedrion18:08:09

oh let me check

octahedrion18:08:52

ahah yes in project.clj I had :before-jsload and :on-jsload

bhauman18:08:26

so go ahead and use the new reloading mechanism and you should be good

bhauman18:08:52

when you have a warning that is preventing reloads

octahedrion18:08:55

and it works!

octahedrion18:08:07

got it - thank you so much for all your help!

octahedrion18:08:10

i completely forgot about :on-load

octahedrion18:08:22

when I switched to deps.edn

bhauman20:08:03

I’m now going to check the reloading is working correctly for code-splitting

octahedrion07:08:05

I added ^:figwheel-load to the namespaces I'm changing but no change

bhauman20:08:08

as it will help you in your current circumstance hopefully