Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we use spiral and ring-reload together? #19

Open
hantuzun opened this issue Aug 7, 2015 · 17 comments
Open

How can we use spiral and ring-reload together? #19

hantuzun opened this issue Aug 7, 2015 · 17 comments

Comments

@hantuzun
Copy link

hantuzun commented Aug 7, 2015

I've tried make spiral and ring-reload work together without success.

I'm getting the following error:

ERROR http-kit - Encountered unhandled error from spiral httpkit adapapter.
java.lang.Exception: Cyclic load dependency: [ /spock/core ]->/spock/rest->[ /spock/core ], compiling:(/private/var/folders/m5/tl2vtswn5sjb4jry7k6x30tr0000gn/T/form-init8541479910851221960.clj:1:198)
    at clojure.core$throw_if.doInvoke(core.clj:5630)
    at clojure.lang.RestFn.invoke(RestFn.java:442)
    at clojure.core$check_cyclic_dependency.invoke(core.clj:5766)
    at clojure.core$load.doInvoke(core.clj:5863)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5671)
    at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
    at clojure.core$load_lib.doInvoke(core.clj:5710)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:632)
    at clojure.core$load_libs.doInvoke(core.clj:5749)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:632)
    at clojure.core$require.doInvoke(core.clj:5832)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at ring.middleware.reload$wrap_reload$fn__471.invoke(reload.clj:17)
    at ring.middleware.json$wrap_json_body$fn__759.invoke(json.clj:46)
    at clojure.lang.Var.invoke(Var.java:379)
    at spiral.core$sync__GT_async_adapter$fn__5831$fn__5832.invoke(core.clj:48)
    at spiral.core$sync__GT_async_adapter$fn__5831.invoke(core.clj:47)
    at clojure.core.async$thread_call$fn__4086.invoke(async.clj:405)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
...

How can we resolve the issue?

Thanks!

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 7, 2015

This looks like a problem with the spock library--are you also using it?

@hantuzun
Copy link
Author

hantuzun commented Aug 9, 2015

Spock is the name of out project :)

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 9, 2015

I don't think spiral does anything weird with loading libs--could you share a simple reproducible case with me, so that I could debug it?

@hantuzun
Copy link
Author

Sure thing, just give me a day or two.

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 10, 2015

Looking forward to it!
On Mon, Aug 10, 2015 at 4:29 AM Emrehan Tüzün [email protected]
wrote:

Sure thing, just give me a day or two.


Reply to this email directly or view it on GitHub
#19 (comment).

@hantuzun
Copy link
Author

Here is it: https://github.com/emrehan/failing-spiral

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 17, 2015

Thanks, I'm looking into this over the next week or so, to come up with a
fix!
On Thu, Aug 13, 2015 at 7:46 AM Emrehan Tüzün [email protected]
wrote:

Here is it: https://github.com/emrehan/failing-spiral


Reply to this email directly or view it on GitHub
#19 (comment).

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 18, 2015

I've got the repro working, and I've discovering a bizarre thing. If I first do a (require 'project.core :reload) and (require 'project.rest :reload), then the bug with ring-reload doesn't show up. It seems something very strange is going on with the namespace dependency tracking and the way that ring-reload handles it, as compared to when I do the requires myself (which seems to initialize something differently).

@hantuzun
Copy link
Author

Oh, that's strange. The issue could be caused by Clojure compiler as well. CLJ-1544 had cost me some time back then.

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 23, 2015

I'm really not sure what's going on. I've further determined that even if I do those requires, then ring-reload definitely invokes using (require ... :reload), but also the source file is not reloaded, so it just silently fails.

Perhaps you could require the specific namespaces yourself from your editor? That's what I do.

@hantuzun
Copy link
Author

@dgrnbrg; how could I require namespaces from an editor? I didn't get it.

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 26, 2015

Which editor do you use? I can give you specific instructions. Basically,
most editors have a keyboard shortcut to do (require 'current-ns :reload)
On Wed, Aug 26, 2015 at 8:32 AM Emrehan Tüzün [email protected]
wrote:

@dgrnbrg https://github.com/dgrnbrg; how could I require namespaces
from an editor? I didn't get it.


Reply to this email directly or view it on GitHub
#19 (comment).

@hantuzun
Copy link
Author

Okay, I use Idea, but I can't see how doing (require 'current-ns :reload) would help a project run without problems.

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 27, 2015

Once you've got the server running, you can reload whichever namespace
you're working in, so that all invocations to the new vars are picked up.
Unfortunately, repl-driven development with core.async is hard, because it
keeps old code running unless you shut it down cleanly.

On Thu, Aug 27, 2015 at 12:49 AM Emrehan Tüzün [email protected]
wrote:

Okay, I use Idea, but I can't see how doing (require 'current-ns :reload)
would help a project run without problems.


Reply to this email directly or view it on GitHub
#19 (comment).

@hantuzun
Copy link
Author

Thanks. Would it help in production?

@dgrnbrg
Copy link
Owner

dgrnbrg commented Aug 27, 2015

I would recommend against using ring-reload or anything like it in
production--the best practice is to create an "uberjar" (which contains all
your dependencies), so that you can trust the state of the deployment.

On Thu, Aug 27, 2015 at 10:18 AM Emrehan Tüzün [email protected]
wrote:

Thanks. Would it help in production?


Reply to this email directly or view it on GitHub
#19 (comment).

@hantuzun
Copy link
Author

Yes, you're right. We're running uberjars as well, but we should use ring-reload only in development profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants