Fork me on GitHub
#tools-deps
<
2022-04-12
>
DenisMc11:04:49

Hi, I’m having a weird problem when using tools.deps that is confounding me. I have a build process using deps that compiles my code, has been working fine. I also have a docker build that also used to work fine, but now hangs when attempting to compile. But, it only hangs in the docker build - it builds successfully locally. (local clojure version 1.11.1.1105, docker version from the clojure-latest image, 1.10.3.1087. I thought the smoking gun was that I recently introduced some futures into the codebase to handle some external services, however when I run kill -3 on the process in the docker image I can’t see any references to the futures I created (and the futures are not in top level functions anyway). When I run lots of kill -3's, the system does seem to be doing work - the main stack trace changes - but it’s crawling along at a snail’s pace. I realise that this could be caused by any amount of errors I’ve introduced myself, but maybe someone on here might have seen this category of problem before and could point me where it may be most fruitful to look and might save me a few hours of my life! Thanks in advance.

Alex Miller (Clojure team)12:04:51

Is the “build process” a tools.build program or something else? Not sure how to help without more info

DenisMc14:04:41

Apologies, should have included that info, it's using clojure.tools.build.api/compile-clj to compile. I'm building an Uber jar after compiling sources but it's not getting that far

Alex Miller (Clojure team)14:04:55

one common reason for compile to take suspiciously long is that you have code at the top level of a namespace that is doing something (compile is a side effect of loading)

Alex Miller (Clojure team)14:04:17

it may be doing something can succeed locally but not in the docker environment, for example

DenisMc14:04:42

When top level, you mean (for example) having a (future) call directly in the namespace, rather than within a (defn)? I have introduced a few futures but from what I can see they are all within other functions.

DenisMc14:04:33

Now that you say it though, the stuff I introduced would fit the bill in terms of working locally and not in docker, so that's definitely a smoking gun.

Alex Miller (Clojure team)14:04:42

yes, any code at the top level of the namespace (def's ) will be loaded and evaluated as part of compilation

DenisMc14:04:09

But defn’s won't?

Alex Miller (Clojure team)14:04:55

no real difference here - each top level form is evaluated. for def , that means evaluating the initialization value. for defn it means evaluating the function definition (but that's not going to invoke the function, unless you cause that to occur)

DenisMc14:04:24

Ah ok, that's clearer now. Thanks for the steer.