lein-figwheel

octahedrion 2018-08-20T08:20:32.000100Z

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 ?

bhauman 2018-08-20T13:44:50.000100Z

@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

bhauman 2018-08-20T13:45:07.000100Z

I wonder why there is one

octahedrion 2018-08-20T13:45:22.000100Z

I'm using code-splitting if that helps

octahedrion 2018-08-20T13:45:49.000100Z

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

octahedrion 2018-08-20T13:47:05.000100Z

oh wait I think I see now

octahedrion 2018-08-20T13:47:13.000100Z

I'm using websockets too

octahedrion 2018-08-20T13:47:37.000100Z

my websocket code could be interfering with Figwheel's

bhauman 2018-08-20T13:49:54.000100Z

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

bhauman 2018-08-20T13:50:36.000100Z

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

bhauman 2018-08-20T13:51:06.000100Z

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

octahedrion 2018-08-20T13:51:23.000100Z

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

bhauman 2018-08-20T13:52:01.000100Z

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

octahedrion 2018-08-20T14:04:57.000100Z

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

bhauman 2018-08-20T14:10:11.000100Z

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

octahedrion 2018-08-20T14:15:02.000100Z

ok i started again, clearing my compile dir etc

octahedrion 2018-08-20T14:17:19.000100Z

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)

bhauman 2018-08-20T14:18:25.000100Z

there’s no stacktrace in the REPL?

octahedrion 2018-08-20T14:18:29.000100Z

no

octahedrion 2018-08-20T14:19:27.000100Z

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

bhauman 2018-08-20T14:19:27.000200Z

are you using the default dev host page?

octahedrion 2018-08-20T14:19:33.000100Z

no

octahedrion 2018-08-20T14:19:55.000100Z

and I have :open-url false

bhauman 2018-08-20T14:20:13.000100Z

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

octahedrion 2018-08-20T14:20:33.000100Z

haven't been required

bhauman 2018-08-20T14:21:30.000100Z

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

octahedrion 2018-08-20T14:22:02.000100Z

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

bhauman 2018-08-20T14:22:11.000100Z

OK cool just checking

octahedrion 2018-08-20T14:22:17.000100Z

it is required by the namespace of the main

octahedrion 2018-08-20T14:22:22.000100Z

for this module

bhauman 2018-08-20T14:23:21.000100Z

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

bhauman 2018-08-20T14:23:38.000100Z

and your program loads and runs

octahedrion 2018-08-20T14:23:41.000100Z

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

bhauman 2018-08-20T14:23:55.000100Z

yeah that should work

bhauman 2018-08-20T14:24:49.000100Z

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

bhauman 2018-08-20T14:25:06.000200Z

but the warning or exception is itself causing figwheel to throw

octahedrion 2018-08-20T14:25:23.000100Z

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

bhauman 2018-08-20T14:25:54.000100Z

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

octahedrion 2018-08-20T14:25:55.000100Z

oh not the 2dn time

octahedrion 2018-08-20T14:26:40.000100Z

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

octahedrion 2018-08-20T14:27:11.000100Z

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

octahedrion 2018-08-20T15:18:18.000100Z

ok I tried without modules and I get the same thing

octahedrion 2018-08-20T15:18:40.000100Z

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

octahedrion 2018-08-20T15:18:59.000100Z

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

octahedrion 2018-08-20T15:19:18.000100Z

it just doesn't reload it dynamically

octahedrion 2018-08-20T15:20:01.000100Z

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

octahedrion 2018-08-20T15:20:10.000100Z

but that's just a warning

bhauman 2018-08-20T20:41:46.000100Z

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

octahedrion 2018-08-21T07:44:15.000100Z

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

octahedrion 2018-08-21T08:59:34.000100Z

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

octahedrion 2018-08-21T09:01:16.000100Z

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

octahedrion 2018-08-21T09:05:33.000100Z

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

bhauman 2018-08-21T12:44:40.000100Z

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

bhauman 2018-08-21T12:45:43.000100Z

@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

bhauman 2018-08-20T20:50:06.000100Z

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

bhauman 2018-08-20T20:56:35.000100Z

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

bhauman 2018-08-20T20:57:34.000100Z

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

octahedrion 2018-08-21T07:45:40.000100Z

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

octahedrion 2018-08-21T07:46:07.000100Z

but I get the same results

octahedrion 2018-08-21T07:49:04.000100Z

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

bhauman 2018-08-21T12:41:04.000100Z

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

bhauman 2018-08-21T12:43:02.000100Z

I just pushed the debugging code

bhauman 2018-08-21T13:02:05.000100Z

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

octahedrion 2018-08-21T13:51:00.000100Z

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

octahedrion 2018-08-21T15:09:03.000100Z

I still get the error though

octahedrion 2018-08-21T15:09:54.000100Z

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

octahedrion 2018-08-21T15:14:20.000100Z

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

octahedrion 2018-08-21T15:53:52.000100Z

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

bhauman 2018-08-21T17:56:41.000100Z

@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

bhauman 2018-08-21T17:57:05.000100Z

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

bhauman 2018-08-21T17:57:41.000100Z

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

octahedrion 2018-08-21T18:14:10.000100Z

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

octahedrion 2018-08-21T18:14:20.000100Z

and then I restarted figwheel main

octahedrion 2018-08-21T18:16:29.000100Z

now get this:

octahedrion 2018-08-21T18:16:31.000100Z

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

octahedrion 2018-08-21T18:20:44.000100Z

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

octahedrion 2018-08-21T18:22:14.000100Z

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

bhauman 2018-08-21T18:22:44.000100Z

on the same codebase?

bhauman 2018-08-21T18:23:15.000100Z

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

bhauman 2018-08-21T18:23:28.000100Z

or is this a different codbase?

bhauman 2018-08-21T18:24:37.000100Z

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

octahedrion 2018-08-21T18:25:06.000100Z

yes with this codebase lein-figwheel works fine

bhauman 2018-08-21T18:25:43.000100Z

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

bhauman 2018-08-21T18:25:59.000100Z

:on-js-reload ?

octahedrion 2018-08-21T18:26:02.000100Z

ummm

octahedrion 2018-08-21T18:26:09.000100Z

oh let me check

bhauman 2018-08-21T18:26:25.000100Z

and for figwheel-main you would use https://figwheel.org/docs/hot_reloading.html#reload-hooks

octahedrion 2018-08-21T18:26:52.000100Z

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

bhauman 2018-08-21T18:27:26.000100Z

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

bhauman 2018-08-21T18:27:38.000100Z

and here’s a reminder to use https://figwheel.org/config-options#load-warninged-code

bhauman 2018-08-21T18:27:52.000100Z

when you have a warning that is preventing reloads

octahedrion 2018-08-21T18:31:55.000100Z

and it works!

octahedrion 2018-08-21T18:32:07.000100Z

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

octahedrion 2018-08-21T18:58:10.000100Z

i completely forgot about :on-load

octahedrion 2018-08-21T18:58:22.000100Z

when I switched to deps.edn

bhauman 2018-08-20T20:58:03.000100Z

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

bhauman 2018-08-20T20:58:48.000200Z

but also make sure you have read https://figwheel.org/docs/hot_reloading.html#force-a-file-to-be-loaded

octahedrion 2018-08-21T07:50:05.000100Z

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

bhauman 2018-08-20T20:59:08.000100Z

as it will help you in your current circumstance hopefully