taoensso / telemere

Structured telemetry library for Clojure/Script
https://www.taoensso.com/telemere
Eclipse Public License 1.0
105 stars 1 forks source link

Compilation error in Shadow-CLJS when Telemere used both in CLJ / CLJS #7

Closed davidyang closed 1 month ago

davidyang commented 1 month ago

Hi @ptaoussanis - I'm trying out Telemere in that same app where I'm running one JVM that boots up both a JVM app and a Shadow compiler. I'm getting this error when trying to build the Shadow app:

[server.log] [:browser-dev] Build failure:
[server.log] ------ ERROR -------------------------------------------------------------------
[server.log]  File: jar:file:/Users/dyang/.m2/repository/com/taoensso/telemere/1.0.0-beta11/telemere-1.0.0-beta11.jar!/taoensso/telemere.cljc:45:1
[server.log] --------------------------------------------------------------------------------
[server.log]   42 |
[server.log]   43 | ;;;; Shared signal API
[server.log]   44 |
[server.log]   45 | (sigs/def-api
[server.log] -------^------------------------------------------------------------------------
[server.log] null
[server.log] set! target must be a field or a symbol naming a var at line 45 taoensso/telemere.cljc
[server.log] --------------------------------------------------------------------------------
[server.log]   46 |   {:purpose  "signal"
[server.log]   47 |    :sf-arity 4
[server.log]   48 |    :ct-sig-filter   impl/ct-sig-filter
[server.log]   49 |    :*rt-sig-filter* impl/*rt-sig-filter*
[server.log] --------------------------------------------------------------------------------
[server.log]
[server.log] 2024-05-14 11:12:27.811 INFO EVENT olorin.localdomain taoensso.telemere.tools-logging(47,3) :taoensso.telemere/clojure.tools.logging->telemere! - Enabling intake: `clojure.tools.logging` -> Telemere
[server.log] 2024-05-14 11:12:27.812 INFO EVENT olorin.localdomain taoensso.telemere.streams(132,10) :taoensso.telemere/streams->telemere! - Enabling intake: standard stream/s -> Telemere
[server.log]    data: #:system{:out? true, :err? true}

I'm guessing it's related to the &env check that later calls a set! in def-filter-api?

ptaoussanis commented 1 month ago

Hi David,

I'm getting this error when trying to build the Shadow app:

Could you please clarify how exactly you're building? A small reproducible example would be ideal if possible, then I can try on my end. I expect that your shadow-cljs config might also be relevant, but I'm not sure.

where I'm running one JVM that boots up both a JVM app and a Shadow compiler

So your app uses shadow-cljs as a library? Is this just for build purposes, or your app actually uses shadow-cljs as part of its core functionality?

davidyang commented 1 month ago

Hi Peter - I've created a basic repository that explains what I'm trying to do. It generates the compilation error if you run the command

clojure -A:server:browser -M -m server.main

https://github.com/davidyang/telemere-bug

ptaoussanis commented 1 month ago

Thanks David, that's great 👍 Will try take a proper look tomorrow, I'm just about to sign off.

In the meantime, could you please provide some context for your approach? I'm not so familiar with using shadow-cljs as a library and it's not obvious to me why one would want to simultaneously run both an app and shadow from the same JVM process.

Is this a common pattern? What's the motivation? I might be missing something obvious, so please explain like I'm five :-)

davidyang commented 1 month ago

My understanding is that this is a pretty common pattern for those of us using VS Code and Calva.

When someone is working on an app with a Clojure server and a ClojureScript front-end and using one VSCode Workspace, Calva and VSCode only allow one nREPL session to one JVM for switching between clj and cljs (shadow) contexts. Calva doesn't support connecting to two separate nREPL sessions like sesman. Therefore Calva users tend to run the Shadow compiler via library calls from the same JVM that runs their HTTP server.

ptaoussanis commented 1 month ago

Thanks for the explanation and reproducible David, those were really helpful 👍

Quick update to say that I've identified the problem and will have a fix up later today.

ptaoussanis commented 1 month ago

Okay, this should be fixed with com.taoensso/encore {:mvn/version "3.111.0"} 👍 The next Telemere beta release will (as always) also include the latest Encore, so will include this fix. In the meantime you can just specify the latest Encore version yourself.

Apologies for the trouble with this!

davidyang commented 1 month ago

Thanks Peter! Updated and looks good over here.

ptaoussanis commented 1 month ago

Thanks for the confirmation!