clj-reload
clj-reload copied to clipboard
defonce flushed on 2nd reload
Hi
i have a weird issue with defonce. On 1st reload the value is kept, on 2nd one it is flushed. Here is the source https://github.com/Madek/madek-api-v2/blob/mk/reload-no-ci/src/madek/api/main.clj#L78
So, after 1st reload https://github.com/Madek/madek-api-v2/blob/mk/reload-no-ci/src/madek/api/main.clj#L102 is executed because the value is still there but after 2nd reload it is (atom nil) again.
All i did in regards to the setup is here: https://github.com/Madek/madek-api-v2/commit/dfce73a69f45c430c7bece325befb2185a510044
The service can be run with ./bin/dev-run-backend
Any help would be appreciated. Thanks.
[~/work/madek-api-v2] ./scripts/start-dev-server
+ lein clean
Couldn't find project.clj, which is needed for clean
Running
clj -M -m madek.api.main
just straight up terminates the process
@tonsky due to THROWABLE: org.postgresql.util.PSQLException: FATAL: database "madek" does not exist
please createdb madek and try again
I'm seeing the same issue. Here's a simple reproduction:
a.clj:
(ns a
(:require [b :refer [bar]]))
(defonce foo (atom nil))
(defn set-foo []
(reset! foo bar))
(comment
(set-foo)
@foo)
b.clj:
(ns b)
(def bar 12)
After evaluating (set-foo), @foo is 12. Change bar in b.clj to a different number, save then run (reload/reload), @foo is still 12. Change bar again, save then reload, @foo is now nil.
Thanks! Will look into it
Should be fixed in 0.9.7