Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node client does not reject promise on unsucessful request #30

Open
martinklepsch opened this issue Apr 26, 2022 · 2 comments
Open

node client does not reject promise on unsucessful request #30

martinklepsch opened this issue Apr 26, 2022 · 2 comments

Comments

@martinklepsch
Copy link
Contributor

martinklepsch commented Apr 26, 2022

(require '[httpurr.client.node :as node])
(require '[promesa.core :as p])

(defn decode
  [response]
  (update response :body #(js->clj (js/JSON.parse %))))

(defn get!
  [url]
  (p/then (node/get url) decode))

This is an example from the docs. In contrast to the client/send! function this won't automatically reject the promise if the request failed. Edit, it seems that even when using client/send! and passing the node client a 400 HTTP code does not cause the promise to be rejected. I'm wondering if this should be considered a bug or if using client specific send! functions should be discouraged / removed from the docs?

I find this behavior is probably worth fixing as the documentation describes multiple ways of making requests with different error handling semantics.

From the docs

send! is a function that, given a request map and optionally a map of options, performs the request and returns a promise that will be resolved if there is a response and rejected on timeout, exceptions, HTTP errors or aborts.

@martinklepsch
Copy link
Contributor Author

Bump :) Is this something you'd consider a PR for? I guess it's somewhat problematic to fix as it would break a lot of clients but maybe we could introduce a node-next namespace with a more strict behavior?

@niwinz
Copy link
Member

niwinz commented Nov 8, 2022

sorry, but I don't have time for it right now
If you wan't to help of taking care of this project, i'm gladly give you commit access to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants