This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-22
Channels
- # announcements (18)
- # babashka (9)
- # beginners (22)
- # biff (2)
- # calva (17)
- # clj-kondo (5)
- # clojure (9)
- # clojure-europe (25)
- # clojure-nl (1)
- # clojure-norway (3)
- # clojure-uk (7)
- # clojuredesign-podcast (6)
- # clojurescript (61)
- # cursive (11)
- # data-science (1)
- # datahike (3)
- # datomic (2)
- # humbleui (2)
- # hyperfiddle (7)
- # jobs (1)
- # jobs-discuss (4)
- # joyride (1)
- # overtone (7)
- # re-frame (2)
- # reitit (9)
- # releases (2)
- # remote-jobs (8)
- # scittle (1)
- # shadow-cljs (48)
- # squint (8)
;; No stacktrace for e:
(go (try (let [result (<p! (some-fn-results-rejected-promise))])
(catch js/Error e
(throw e))))
;; There is a javascript stacktrace
(go (try (let [result (<p! (some-fn-results-rejected-promise))])
(catch js/Error e
(throw (js/Error e)))))
;; is it possible to access to cljs stacktrace? (which means i'll see that the error came from "some-fn-results-rejected-promise")?JS doesn't have the concept of rethrowing exceptions like Java, so doing that is lossy
like I said .. do not use core.async for this. Browsers have special support for Promises and async stacktraces, which is built-in and not extensible. Since Browsers do not know core.async they cannot do this stichting together of traces
Hello, I've again run into an API that wants me to use an AsyncIterator:
for await (const [key, value] of this.keyv.iterator()) {
console.log(key, value); // Return: key and value
};
I did a search here and came up with the following links:
https://ask.clojure.org/index.php/10896/how-to-work-with-asynciterable-interface-in-cljs
https://clojure.atlassian.net/browse/ASYNC-239
Which looks like there's no nice clean way to handle these. What's the current best practice for handling this situation in CLJS?well, this was an unpleasant surprise.. this physics engine, rapier, uses super small floats as IDs and
(= (hash -0.32553251) (hash -0.0000032553251))
is there a fast alternative?
Alternative to what? hash
? Or the engine?
Why do you need to compare hashes in the first place?
You can store keys in a map that all have the same hash.
But since those IDs are small, they will all have the same hash, which will result in O(n) access/insertion times.
You can't override the built-in hash
, but you can create an alternative map data structure implementation that uses a different hashing. E.g. you can first (* id 1000000)
and hash it after or something like that.
Alternatively, you can use a tree map.
Both approaches introduce an issue where you have to painstakingly make sure that the map type is the one you expect.
Also, maybe the multiplication route is not feasible if the numbers can get quite big. In that case, it would make sense to come up with a proper hashing approach.
yeah, I'm aware of the degenerate behavior đ it's not the behavior in clojure or any other language i've used, so it's surprising. custom map type doesn't sound bad, just have to be careful about using these handles anywhere else I guess
There's at least one instance where the bindings split some ID-looking f64
into two u32
. Perhaps you can do the same and have a map not like id->something but [u32, u32]
->something.
I just converted the ID handle back to the js object it represents to use that as the key instead, I hash it elsewhere already so goog/getUid should already be cached, guessing it's pretty fast anyway
Just in case - getUid
mutates the object. If that object cannot be mutated or is recreated, the value will be wrong.
cljs.user=> (def x (js/BigInt 7))
#'cljs.user/x
cljs.user=> (hash x)
1
cljs.user=> (hash x)
2
cljs.user=> (hash x)
3
the hashing thing doesn't really have anything to do w/ JavaScript - JavaScript doesn't have hashing
I added a bunch of comments on how I think it can be done - happy to see someone try it - will take look soon if no one else does
Curious - is that if-not
a personal preference?
Also, are there any notable performance considerations?
when it comes to hashing I just defer to whatever Clojure does - and if it bottoms out in JDK whatever JDK does
> ... but it did remind to add a missing ^boolean
Oh... huh. Is there no way to do that automatically for all the known methods that always return a boolean?
I feel like there's been a discussion or maybe even an issue about but can't recall exactly.
hrm, you're right that we can figure this out from externs, but I don't know if this case works
I believe fixed, thanks for the report - https://github.com/clojure/clojurescript/commit/54c27fbdf884142ac4e0d9d4ed38ec119905f17e
Hello folks! Any tips how to troubleshoot âMax. call size stack exceededâ when the stack trace only contains core fns and none of my code? > Uncaught RangeError: Maximum call stack size exceeded > at Object.eval [as cljs$core$ILookup$_lookup$arity$2] (core.cljs:6871:1) > at Function.eval [as cljs$core$IFn$_invoke$arity$2] (core.cljs:1960:18) > at Object.eval [as cljs$core$IFn$_invoke$arity$1] (core.cljs:3354:6) > at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (core.cljs:10289:20) > at Object.cljs$core$print_prefix_map [as print_prefix_map] (core.cljs:10560:4) > at Object.cljs$core$print_map [as print_map] (core.cljs:10574:8) > at Object.eval [as cljs$core$IPrintWithWriter$prwriter$arity$3] (core.cljs:10649:6) > at Object.cljs$core$prwriter [as prwriter] (core.cljs:778:16) > at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (core.cljs:10360:10) > at cljs$core$pr_writer (core.cljs:10442:6) đ
What user action results in this exception? Seems like printing some object. So I'd inspect that object.
my first guess would be printing an atom containing itself, but that would have a deref in the trace
That is the full stack trace that is printed. No user action, just loading my app. Printed by React ErroubBoundary, I know this happens in one particular component. But cannot find out what is trying to print what.
Yes, I too suspect it is some infinite data problem, just need to find out where.
The question is where to set it đ
Thank you, that helped!
this could just be a side effect of something else calling theObject.toString()
which invokes the printer
When fulcro inspect installs itself, it tries to print something that blows up it seems.
Though the paticular line is (log/info "Installing Fulcro 3.x Inspect" {})
so it is perhaps soemthing in Timberâs context or somethingâŚ
Do you have *print-level*
bound? https://clojuredocs.org/clojure.core/*print-level*#:~:text=*print%2Dlevel*%20controls%20how,the%20maximum%20level%20to%20print.
my bad, it might not be that pr-write that triggers the exc. but an earlier one đ
FYI I found it, it was my own pr-str
one place in the code
I guess the thing I tried to print was simply too large
Thank you all for your help!
"too large"? In a sense, but a stack overflow makes me think the "size" had to do with depth, and possibly a cyclic structure. That is why I asked about *print-level*
. Binding that to some modest integer will let you see much of the data, but only so many levels deep.
You are most likely right that there was a cycle.
If so, (binding [*print-level* 3] (prn <cyclic data>))
(untested) should work.