gnarroway / hato

An HTTP client for Clojure, wrapping JDK 11's HttpClient
MIT License
380 stars 27 forks source link

Inconsistent Behavior with Async Requests #16

Closed rschmukler closed 4 years ago

rschmukler commented 4 years ago

Hey! Thanks for all your work on this library. I'm currently exploring replacing aleph with it and noticed an interesting behavior.

When making a synchronous request, exceptions are thrown, however the default function for raise is identity. This means that async exceptions are returned as values.

I would expect that by default (http/get url) and @(http/get url {:async? true}) would behave identically. Furthermore this will result in unexpected behavior when using libraries like manifold:

(d/catch (http/get "https://thisdoesntexistlol.com" {:async? true})
  (fn [err]
    (log/warn err "Error making request")))

Is this intentional?

Thanks again!

gnarroway commented 4 years ago

Hi,

Thanks for catching this. You are absolutely correct and this is an unintentional bug. I've added a fix in 0.7.0-SNAPSHOT, which will be released soonish. Let me know if it works for you.

rschmukler commented 4 years ago

I've confirmed that this is fixed in 0.7.0-SNAPSHOT. Thanks for the quick response and looking into it! Cheers.

This was fixed in f41e9196af62d1ba4f6b9d6f545f6abff272802c