This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-02
Channels
- # announcements (3)
- # asami (29)
- # babashka (62)
- # beginners (131)
- # biff (7)
- # calva (31)
- # cider (5)
- # clerk (14)
- # clj-kondo (3)
- # cljsrn (12)
- # clojars (18)
- # clojure (72)
- # clojure-austin (17)
- # clojure-dev (6)
- # clojure-europe (31)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-norway (18)
- # clojure-sweden (11)
- # clojure-uk (6)
- # clr (47)
- # conjure (42)
- # cursive (88)
- # datalevin (2)
- # datomic (25)
- # emacs (42)
- # exercism (1)
- # fulcro (10)
- # funcool (8)
- # gratitude (2)
- # honeysql (16)
- # introduce-yourself (5)
- # jobs-discuss (26)
- # leiningen (5)
- # lsp (31)
- # malli (21)
- # matcher-combinators (14)
- # missionary (2)
- # nbb (1)
- # off-topic (40)
- # pathom (38)
- # portal (2)
- # re-frame (7)
- # reagent (18)
- # reitit (1)
- # releases (5)
- # shadow-cljs (62)
- # sql (12)
- # testing (4)
- # xtdb (37)
In my init-fn
I try to disable logging like this:
(ns app.entry
(:require
[app.core :as core]))
(defn init []
(js/console.log "Initializing app!")
;; (when-not ^boolean js/goog.DEBUG)
(set! *print-fn* (fn [& _]))
(js/console.log "This shouldn't appear.")
,,,,)
But it never works. It does if I eval the set!
call manually though. Any ideas on what might be causing this?that is to say js/console.log
is not affected by *print-fn*
, prn
or others use *print-fn*
which defaults to using js/console.log
Ooooooh. That makes sense. So I should replace every call to js/console.log
with println
?
Wait but then that doesn't appear in the browser console. Hmmm.
Not println
but prn
Ah. (set! js/console.log (fn [& _]))
does the trick
My goal is to have the same level of stack trace information in shadow development mode locally as i get from the logrocket (a screen capture service). I uploaded my source maps to them, and it now i'm getting almost the ideal set of information. See in LR, the stacktrace tells me the file where the issue happened (see screenshot): js/cljs-runtime/centriq_web.admin.js:428 but in my local browser i get the location in the cljs file, which is way better. e.g (admin.cljs:579:36). Is there a way in general to do this? My understanding is that we compile cljs to js to minified js, the source map is for the second compile step. Are people able to trace it all the way back to the first one?
by default they are disabled for release
builds, you can enable them by setting :compiler-options {:source-map true}
logrocket is pointless for local development on my computer. It captures user sessions in production. If the encounter a js error, without further information (source maps) for us, the error it gives us is compressed js. I attempted to give LR source maps according to there instructions, and now it tells me the JS file where the error happened, but i'm hoping i can get it to tell me the cljs file and line number.
which source map did you give them? since the above is at most from a development build?
it is not from a release build. I assume you are not serving your users development builds?
> it is not from a release build. I assume you are not serving your users development builds? I'm not. I did a release then uploaded that source map. then i started my shadow server locally and LR is tracking that session. Likely i need to do a release, upload that, then run that release locally.
you generate a release build. it generates a matching .map file, that ONLY matches that JS output.
Thanks for the help. This largely isn't a shadow question. I was more asking if people using error reporting tools for production apps were able to get those tools to report the exact line the error happened at in the original cljs file. If everyone said no then i would assume there was some huge obstacle there. What i want is to log into logrocket, view a production user session, and if they had a js error, have log rocket tell me where in the cljs file the issue happened. If you don't upload sourcemaps, what it tells you is the location in the js minified file, because thats all it has. In my attempt to develop on this feature, i'm trying to use a locally running version of the app on my computer. LR has no probably tracking that session, just like i can track any session. I think my mistake is thinking the release build would be identical to what the shadow server build was producing. I should just run the release locally and see if its working as expected. The alternative is that i configure LR, upload the assets, and wait for a staging build. That has like a 15 minute turn around time. so if for some reason the configuration is wrong, it takes a long time to adjust.
you have several option to do that https://shadow-cljs.github.io/docs/UsersGuide.html#_cacheable_output
and you need the EXACT output of the exact build, not a different build. the same map and matching JS file
yes, you cannot just run release
locally again. that will give you a different build
if you version it from the beginning you'll have an easier time figuring out which JS caused the problem
that makes sense, I think your right that would be necessary for this to work properly. If done correct, is it possible to get the same error report we get locally from an error that happened to a user using the minified release?
Let me try to explain again, this is useful for me because its possible i'm barking up the wrong tree. Logrocket downloads the js file from a user session that we have allowed it to track, If an js error happened in that session, LR will show where in the js file it downloaded that error was. In a minified file that looks like this:
adow$provide[0]=function(T,I,ia,ha){var E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;ia.exports=function(){try{if(!Object.assign)return!1;var h=new String("abc");h[5]="de";if("5"===Object.getOwnPropertyNames(h)[0])return!1;var k=
the line number in the minified file, and the accompanying text (above) isn't useful for debugging the issue. So i need to unminify it, and then map it back to the cljs. I assume that's possible, but i haven't read a tutorial on it, i haven't seen it done, and yet it would seem like an obvious thing to want. If this works out, maybe ill write the tutorial, then discover there are like 10 of them already, i just failed to find them.
assuming the code above sits in a app.v1.js
file and you have uploaded a app.v1.js.map
file to LR, you should get proper stacktraces already
I agree. My hope was that the only thing i had to do was upload the source maps. Thanks a ton, i'm pretty confident on what i have to do now.
yep, total makes sense. 🙂 Thanks for your patience and support.