Fork me on GitHub
#clojurescript
<
2022-11-16
>
Drew Verlee02:11:33

I'm getting errors like `cljs.core/&lt;, all arguments must be numbers, got [#{nil clj-nil} number] instead` , as a starting point, what is a [#{nil clj-nil} number]?

Drew Verlee02:11:58

err that's probably just a vector?

Drew Verlee02:11:44

what is a clj-nil then?

Drew Verlee02:11:07

i guess it's not important, in that it's not a number...

skylize03:11:34

Github search is not great. But looking through https://github.com/clojure/clojurescript/blob/9562ae11422243e0648a12c39e7c990ef3f94260/src/main/clojure/cljs/analyzer.cljc, I get the impression maybe clj-nil is a symbol that internally represents the combination of null and undefined? Found this, which definitely seems relevant to your query. Seems that since 1.10.741, it is in fact "not a number". 😄 > from Changelog for v1.10.741 > • CLJS-3086: Switch clj-nil to not be considered a numeric type

👀 1
skylize03:11:10

Looks like you have (a vector of (a set of nil and clj-nil) and a number). Don't know if spelling that out explicitly helps you any with figuring what went wrong.

👍 1
Drew Verlee06:11:49

thanks, yeah that helps at least i know what i'm looking at.

Alexis Schad08:11:12

[#{nil clj-nil} number] is the types of the arguments, so you gave a #{nil clj-nil} as first argument (probably after calling a function) and a number as of second.

Valentin Mouret10:11:58

Hello, I am having this error and I can’t figure out where it comes from. Most likely it’s from something I am doing, but I find no references to my code in the trace, only ClojureScript and reagent. The behaviour is super weird as well. It happens after the first load when I search for the first time (in the search bar I made). If I reload the page (so, same state I suppose (re-frame+shadow) and search again, it works well. I can only reproduce by closing the page, opening a new one, a searching for the first time. 🤷 Does it ring a bell to aynone?

Valentin Mouret10:11:13

And it comes and goes. Now, I cannot reproduce the error anymore… Probably shadow listens to Slack or something. 😛

Valentin Mouret10:11:58

And back again… wtf

Valentin Mouret10:11:38

My component looks like this if it can help:

(defn search-bar
  "Search bar where the user can input its origin."
  []
  (let [origin (reagent/atom nil)]
    (fn []
      [:div {:style {:padding "9px"}}
       [:input {:type         "search"
                :style        {:border "none" :width "100%"}
                :placeholder  "Paris..."
                :value        @origin
                :on-change    #(reset! origin (-> % .-target .-value))
                :on-key-press #(when (-> % .-key (= "Enter"))
                                 (>evt [:eve.events.api/search @origin {:clear true}]))}]])))

Valentin Mouret10:11:17

>evt is just re-frame/dispatch.

thheller10:11:53

in general when looking at stacktraces do not look at the first line

thheller10:11:15

look for the first reference of your code

Valentin Mouret10:11:29

Yeah, there is none

thheller10:11:55

what is the rest of the stacktrace then?

thheller10:11:26

could be a problem in the event handler?

thheller10:11:55

the error you get when calling nil as a function

thheller10:11:15

so f being nil and (f 1 2 3) or so

thheller10:11:38

maybe you call something that isn't yet set on load

Valentin Mouret10:11:51

There are three logs, apparently the same. The traces are then: 1. cljs.core, reagent.ratom, day8.reagent.impl.batching 2. cljs.core, reagent.ratom, day8.reagent.impl.batching 3. day8.re-frame_10x.inlined_deps.re-frame….re-frame.router

thheller10:11:26

hmm so its re-frame-10x, not even your code?

thheller10:11:51

then I don't know. could be timing issue I guess

Valentin Mouret10:11:07

That’s a dependency I have to have a tracing interface in the browser.

Valentin Mouret10:11:11

My event handler is quite straightforward, I don’t see what could not be set:

(re-frame/reg-event-fx
 ::search
 (fn [{:keys [db]} [_ stop-name & [opts]]]
   (let [connections-request (query {:method     :get
                                     :uri        (url (str "/connections?stop_name=" stop-name))
                                     :on-success [::set-connections]
                                     :on-failure [::raise-http]})
         origin-request      (query {:method     :get
                                     :uri        (url (str "/stops?name=" stop-name))
                                     :on-success [::set-origin]
                                     :on-failure [::raise-http]})]
     {:http-xhrio [connections-request
                   origin-request]

      :db         (let [with-search (assoc db :search/origin stop-name)]
                    (if (:clear opts)
                      (assoc with-search :origins (list))
                      with-search))})))

Valentin Mouret10:11:30

Most likely it has to do with this extension/plugin. Thanks for your answer, I was afraid I was missing something obvious. 🙂

Valentin Mouret12:11:28

I think I made some progress. Actually the problem occurs after page reload too, it just appears random. Since there are no «obvious» mistakes after investigation, I decided to poke where the more impure stuff happens, and it’s in this handler above. Two requests are made concurrently. I tried disabling the origin-request one, and the problem never occurs. I re-enabled it and disabled connections-request and now the problem always occurs. I suspect something is messy in my subscriptions and it works only in a given order of the responses.

Valentin Mouret12:11:45

The stack-trace was not very helpful 😅 .

Valentin Mouret12:11:15

Also, I noticed that the 10x reference only appeared when the panel was open on the page. So, it could not be the cause.

Valentin Mouret12:11:07

And here it is! I was «expecting» the «origin» response to come after the other one which is essentially building a map. I then used this map as a function in a filter. 💥 💥 💥

edipofederle18:11:27

Hi all, Trying to setup some tests on a CLJS project using doo (https://github.com/bensu/doo) my file structure is something like: The src/ src/ ├── clj │ └── my_project │ ├── handler.clj │ └── server.clj ├── cljc │ └── my_project │ └── util.cljc └── cljs └── my_project ├── core.cljs .... The test/ test/ └── cljs └── my_project ├── core_test.cljs └── runner.cljs in the project.clj:

{:cljsbuild
  {:builds
   {:browser-test {:source-paths ["src/cljs" "test/cljs"]
                   :compiler {:output-to "out/runner.js"
                              :main my-project.runner
                              :optimizations :none}}}...
The core_test.cljs and runner.cljs: (ns my-project.runner (:require [doo.runner :refer-macros [doo-tests]] [my_project.core-test])) (doo-tests 'my_project.core-test) (ns my-project.core-test (:require [cljs.test :refer-macros [deftest is]])) (deftest foo-test (is (= 10 10))) Trying to run with: lein doo phantom browser-test the result:
Building ...
#error {
 :cause Assert failed: Namespace my_project.core-test does not exist
(ana-api/find-ns ns)
 :via
 [{:type clojure.lang.ExceptionInfo
   :message nil
   :data #:clojure.error{:source #object[java.io.File 0x3f8bd4b1 test/cljs/my_project/runner.cljs], :line 5, :column 1, :phase :macroexpansion, :symbol cljs.test/test-ns-block}
   :at [cljs.analyzer$macroexpand_1_STAR_$fn__2705 invoke analyzer.cljc 3892]}
  {:type java.lang.AssertionError
   :message Assert failed: Namespace my-project.core-test does not exist
(ana-api/find-ns ns)
   :at [cljs.test$test_ns_block invokeStatic test.cljc 373]}]
 :trace
Somethings with the source paths looks like, but cannot see the issue.. any help will be appreciated.

thheller18:11:50

make sure you are consistent with file names and namespaces

thheller18:11:00

_ in filenames become - in namespace names

thheller18:11:16

my_project.core-test is breaking that rule and should be my-project.core-test

edipofederle20:11:51

@U05224H0W thanks for the reply, actually is correct named on my local, I just write wrongly here…