Fork me on GitHub

I found a bug using my navigation functions; I bound in my emacs commands like:

(portal.web/eval-str "(portal.ui.commands/select-root portal.ui.state/state)")
now, I have two commands select-next and select-prev, and they work initially, but if I go very fast between them, at a certain point they will stop working. This is not the only time in which this happens, but is a reproducible behaviour for me. How could I debug this?


In particular, this definition:

(defn eval-str [code]
  (let [response (c/request {:op :portal.rpc/eval-str :code code})]
    (if-not (:error response)
      (:result response)
      (throw (ex-info (:message response)
                      {:code code :cause (:result response)})))))
I see that if the response is an error, we throw it, but I never saw the error when using a cljs repl


hmm, I restarted my repl and I'm not able to reproduce the issue anymore (which, on one hand, makes me very happy 😂 )


Interesting, let me know if this happens again. Hopefully not 🤞

Daniel Slutsky23:04:11

Hi. Something strange: trying to submit random plots to Portal, I repeatedly get plots that all look like the first one. Calling this a few times

(-> [:portal.viewer/vega-lite 
      {:y {:field "y", :type "quantitative"},
       :x {:field "x", :type "quantitative"}},
      :mark {:type "circle", :size 500},
      :data {:values
              (for [i (range 9)]
                {:x i :y (rand)}))}}]
    (#(do (println %)
gives me identical plots, while the printed values are different each time.


I'm seeing the same thing. I'll see about fixing it, thanks for the bug report 🙏


So I think this is the result of how cljs does hashing for floats :thinking_face:


;; in cljs
(hash 0.0) ;; => 0
(hash 0.5) ;; => 0
(hash 1.0) ;; => 1
(hash 1.5) ;; => 1


If you submit a value in between both charts, it should work 👌


Not sure how to fix this within portal


For now, something like:

(-> [:<>
     {:key (rand)}
       {:y {:field "y", :type "quantitative"},
        :x {:field "x", :type "quantitative"}},
       :mark {:type "circle", :size 500},
       :data {:values
               (for [i (range 9)]
                 {:x i :y (rand)}))}}]]
should fix it 👌

Daniel Slutsky05:04:41

Fascinating. Good idea to use the key. Thanks!!


Depending on values that are not equal having hash codes that are not equal sounds like a bug


Hashes collide


Indeed it is, but the existing solution works well enough for now given implementation constraints. We can log it as an issue, and if enough people run into it, we can look into a long term solution 👌

Daniel Slutsky05:04:00

Thanks. Makes sense. I'll write an issue.

🙏 1