Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

node client does not reject promise on unsucessful request

Aperta
#30 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Ambito
api, backend

Direzione di ricerca

Inizia dai punti di ingresso node/get e client/send! descritti nell’esempio, quindi confronta la loro gestione delle risposte HTTP non riuscite con il contratto documentato delle promise. Esamina la documentazione della richiesta e determina se debba cambiare il comportamento o la documentazione; il lavoro è concluso quando la semantica di gestione degli errori scelta è coerente e documentata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

(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.

Lingua principale
Clojure
Stelle
67
Fork
16
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di funcool/httpurr

Tutte le issue di funcool/httpurr

Issue simili

Altre issue su Clojure

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.