theasp / sente-nodejs-example

Node.js Sente reference example
Eclipse Public License 1.0
10 stars 2 forks source link

Invariant violation in `taoensso.sente:?` #4

Closed gaborbarna closed 8 years ago

gaborbarna commented 8 years ago

Hi,

running the example nodejs client produces the following error:

Successfully compiled "target/node-client.js" in 7.069 seconds.
Hello nodejs!

/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/cljs/core.cljs:10262
  (let [e (js/Error. message)]
          ^
Error: Invariant violation in `taoensso.sente:?` [pred-form, val]:
 [([:el #{"https:" "http:"}] protocol), <nil>]
    at new cljs$core$ExceptionInfo (/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/cljs/core.cljs:10262:11)
    at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/cljs/core.cljs:10294:5)
    at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2 (/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/cljs/core.cljs:10292:16)
    at cljs$core$ex_info (/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/cljs/core.cljs:10289:1)
    at taoensso$truss$impl$default_error_fn (/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/taoensso/truss/impl.cljs:51:13)
    at taoensso$truss$impl$_invar_violation_BANG_ (/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/taoensso/truss/impl.cljs:147:6)
    at /Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/taoensso/sente.cljc:1324:21
    at taoensso$sente$get_chsk_url (/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/taoensso/sente.cljc:1324:21)
    at /Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/taoensso/sente.cljc:1382:20
    at Function.taoensso.sente.make_channel_socket_client_BANG_.cljs$core$IFn$_invoke$arity$variadic (/Users/gbarna/Dev/etc/sente-nodejs-example/target/node-out/taoensso/sente.cljc:1383:19)
theasp commented 8 years ago

@ptaoussanis, could you take a peek at this?

ptaoussanis commented 8 years ago

Hi there,

[pred-form, val]: [([:el #{"https:" "http:"}] protocol), ]

This error means that there's a check somewhere against a protocol symbol to make sure that it's value is either "https:" or "http:". The check is failing since its actual value is nil.

Sounds like the option at https://github.com/ptaoussanis/sente/blob/7de691ed3b0d0e727fdeb791378b0476a200bedd/src/taoensso/sente.cljc#L1357 needs to be specified but isn't.

Does that help / make sense?

theasp commented 8 years ago

Thanks Peter! I take it the snapshot previously did not require this. I've set :protocol to :http in a59b260cdab0adc836a97404673978c7ce0bd9f0.

ptaoussanis commented 8 years ago

take it the snapshot previously did not require this.

Thanks for explicitly mentioning this, it's a regression- the fallback to default value is broken. Will fix.

Cheers!

ptaoussanis commented 8 years ago

I take it the snapshot previously did not require this.

Actually, just checked - and the fall back is indeed working correctly (i.e. as it used to). The salient difference is that there wasn't an invariant check before so some unspecified behaviour was getting through silently.

It seems reasonable to just default to :http when no protocol or window location are available. Will update.