taoensso / sente

Realtime web comms library for Clojure/Script
https://www.taoensso.com/sente
Eclipse Public License 1.0
1.74k stars 193 forks source link

Impossible to handle `:chsk/bad-package` properly #346

Closed p-himik closed 1 year ago

p-himik commented 4 years ago

Consider a scenario where a client cannot decode a message sent by a server. In this case, it results two messages in the JS console:

DEBUG [taoensso.sente:210] - Bad package: <bad_data> <decode_error>
WARN [taoensso.sente:1094] - Cb reply w/o local cb-fn: :chsk/bad-package

The warning message is created by this piece of code:

(if-let [cb-uuid ?cb-uuid]
  (if-let [cb-fn (pull-unused-cb-fn! cbs-waiting_
                                     cb-uuid)]
    (cb-fn clj)
    (warnf "Cb reply w/o local cb-fn: %s" clj))
  (let [buffered-evs clj]
    (receive-buffered-evs! chs buffered-evs)))

The issue is that in the problematic case, cb-uuid is set to the bad_data. It's not nil so the error gets sent into the console and nowhere else.

Folcon commented 4 years ago

I'm putting this here because I think this is related to the current issue, if not, happy to open a new one. The current situation isn't much better, printing this in console:

#error {:message "Invalid event", :data {:given :chsk/bad-package, :errors {:wrong-type 
{:expected :vector
 :actual {:type, :value :chsk/bad-package}}}}}

I can usually debug this by slowly filtering out stuff until I get to what's wrong, it would be useful if it stated what value was at fault?

ptaoussanis commented 1 year ago

@p-himik, @Folcon Apologies for such a long delay replying!

Thanks both for pinging about this, will be fixed in forthcoming v1.18 release 👍