This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-17
Channels
- # adventofcode (23)
- # announcements (2)
- # aws (11)
- # babashka (181)
- # beginners (59)
- # chestnut (2)
- # clj-kondo (9)
- # clojure (90)
- # clojure-brasil (2)
- # clojure-europe (18)
- # clojure-italy (24)
- # clojure-nl (9)
- # clojure-spec (3)
- # clojure-uk (28)
- # clojured (4)
- # clojuredesign-podcast (3)
- # clojurescript (12)
- # community-development (49)
- # core-async (49)
- # cryogen (5)
- # cursive (16)
- # data-science (1)
- # datascript (7)
- # datomic (54)
- # defnpodcast (4)
- # events (2)
- # figwheel-main (14)
- # fulcro (139)
- # graphql (1)
- # jobs-discuss (6)
- # kaocha (1)
- # luminus (2)
- # malli (3)
- # music (1)
- # off-topic (34)
- # pathom (24)
- # re-frame (13)
- # reitit (5)
- # shadow-cljs (8)
- # test-check (6)
@caio Can you explain the problem you are trying to solve? Since requests sent to agents are queued, how would you want the agent to behave in this case, and how would you expect additional send
or send-off
calls to behave?
Might be just overly defensive programming from me, but the use case is a stuartsierra.component that uses agents internally to manage state. I wanted to make sure that on stop
the agents stop receiving messages and then wait for every agent to finish processing the existing messages and then return. I know that by the time stop is called on this component, there shouldn't be any new messages about to arrive, but I want to be extra safe
The exception happens when I run cloverage on my project. But the stack trace doesn’t show where the cycle is
@U7V9HE682 Do you mean between namespaces?
clj-kondo has a tool for this: https://github.com/borkdude/clj-kondo/tree/master/analysis#circular-dependencies
What are peoples tips on creating docker images. I have started again with clojure and getting into the whole deps.edn lifestyle. I used one of these packaging tools to build an uberjar. How do I now build th image? Should I just do that total outside of clojure tools?
building an image is ci/cd job. If you use github use github actions. At least it is me recommendation.
name: master -> docker
on:
push:
branches:
- master
jobs:
build-docker:
runs-on: ubuntu-18.04
steps:
- name: checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- run: docker build . -t {{ github.repository }}/golem:latest
- run: docker login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }}
- run: docker push {{ github.repository }}/golem:latest
- name: Slack notifications
uses: 8398a7/action-slack@v2
with:
status: ${{ job.status }}
author_name: GitHub Actions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
and yes, build image outside of Cloure. Building image using lein build-image
or something like that is not how it should be
At least it is my opinion. All kind of compilation of third party code or whatever shouldn’t be done by lein
- so that is why I like deps.edn
. I see developers without DevOps experience put this things into what they know, so in Clojure only because they can. But it is not the right approach. It should be done by ci/cd solutions. Otherwise project.clj do job which shouldn’t do, it is complex, run things with assumption you have something installed on your localmachine to run REPL etc.
project.clj and lein should be only about application, not about infrastructure etc.
Yeah, I agree about not adding anything Docker-related to project.clj
or deps.edn
. But I'm not sure it's bad to build images locally if you have a proper Dockerfile
.
I now realize that I might've misunderstood the initial premise. Yeah, docker hub or wherever you have to deploy it.
you can, but it is always the place to make a mistake when you are tired. Push the image which you did temporary for debug purpose or experiments.
While you back to project after half a year you have to remember what to do to deploy
I always do ci/cd and I even run dev environment in docker-copmose.yaml instead of brew install foo
I'd say just take a day off in that case. :D Not being able to concentrate can definitely lead to errors in all sorts of places, not just when deploying/publishing an image.
And the best thing for me is: I don’t have to remember or trust doc about how to test or deploy things
clojure -A:depstar -m hf.depstar.jar form-validation-cljs.jar -v
you can build jar like that from deps.edn
Do it in Dockerfile
hello, suppose i start a websocket server in my repl and then lose the handle on it. is there any way of closing it, namely by somehow clearing everything running in that repl session?
are you using component/integrant? while those don't make the issue impossible, it happens far less often
When you lose the handle to it, won't it be garbage collected? Sorry, not too familiar with REPL internals.
it depends on whether it has a gc root (which in turn partly depends on the lib you used to manage your websocket, if any)
eg. sente keeps a data structure full of websockets that are active, so its sockets won't gc until you ensure they are disposed of
yes, keeping IO-related connections open is a good way to create a memory leak (in case you ever face that interview question ;p)
I just noticed that my Component system is being start
ed as part of the lein uberjar
process. That doesn't seem clean, as compiling code shouldn't trigger side effects. It also occasionally breaks my CI build when some of these side effects encounter something unexpected
Any idea of what could be causing this? Maybe there's a gotcha related to Clojure AOT compilation, or uberjarring etc
I certainly have nothing silly in place, like a top-level side-effect or top-level invocation to (component.repl/reset)
.
@vemv "compiling code shouldn't trigger side effects" - clojure has no "compile mode" - if something is at the top level of your file, it runs when loading the file, period
so all it takes is defining the system, to create it when aot compiling
sometimes you can correct this with a delay
which you force via @
for usage, the cleaner solution is to create your system only inside -main, and have a helper function for the repl that you run by hand
If calling load-file
on a file, or require
on a namespace, causes some function to be called, then so will compiling the file.
The thing is, I only create define defn
s. Essentially my project's namespaces only contain defns
and no top-level side effects (like (do-something!)
). I don't expect compilation to invoke any of these defns
@vemv to narrow down what creates the system, you can explicitly print the current thread's stack trace inside the function that creates the system
there are a few -main
defns in different namespaces, so I was thinking whether uberjar could be invoking a random one
it won't invoke any -main when compiling
No def
forms?
(Thread/dumpStack)
Thankfully I only have dev/dev.clj
, outside of the uberjar target paths
(require 'dev)
fails (as it should) in prod
You may not know what a top level side effect is, so when you say you don't have any, that may be incorrect
You can convey the same message without implying I don't understand certain concept :)
But yeah, grepping or reasoning can always fail, so I'll Find your call to component/start, add logging and work backwards
alright, I'll satisfy your curiosity (at the expense of saying something embarassing): the system wasn't being actually being run - instead some side effects were legitimately running as part of the uberjar process (which has various :prep-tasks
steps)
i.e. false diagnostic induced by some extraneous output and bit of a contrived build (which I authored ;p)
so sorry for the noise! At least I learned about (Thread/dumpStack)
(throwing an exception would have worked as well, although (Thread/dumpStack)
seems cleaner as throwing an exception may fail CI for unrelated reasons, before the bug happens)
Another thing I do is create and print the stack trace for an exception, without throwing it. This is better than a full dump if you have lots of threads and only need the current stack. For example:
(.printStackTrace (IllegalStateException. "debug") System/out)
the method I shared above only prints the trace for the current thread as well
oh, you're right! thanks.
but sometimes (.printStackTrace (ex-info "debug" {... ....})
if you also want to pretty print some data in context
Makes sense.
(ins)user=> 42
42
(cmd)user=> (.printStackTrace (ex-info "debug" {:*1 *1}) System/err)
clojure.lang.ExceptionInfo: debug {:*1 42}
at user$eval22.invokeStatic(NO_SOURCE_FILE:1)
at user$eval22.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:7176)
at clojure.lang.Compiler.eval(Compiler.java:7131)
at clojure.core$eval.invokeStatic(core.clj:3214)
at clojure.core$eval.invoke(core.clj:3210)
at clojure.main$repl$read_eval_print__9068$fn__9071.invoke(main.clj:414)
at clojure.main$repl$read_eval_print__9068.invoke(main.clj:414)
at clojure.main$repl$fn__9077.invoke(main.clj:435)
at clojure.main$repl.invokeStatic(main.clj:435)
at clojure.main$repl_opt.invokeStatic(main.clj:499)
at clojure.main$main.invokeStatic(main.clj:598)
at clojure.main$main.doInvoke(main.clj:561)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:37)
nil
I've got a luminus site which is giving 403 errors on one page which doesn't require a login, but it looks to me like everything is okay. The csrf is injected into the page during the GET request, and I can see the __anti-forgery-token: ...
in form params on the POST. Not sure what's missing.
Anyone have a clue?
done ty