Make request errors have original error codes.

Aperta
#37 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
api, backend

Direzione di ricerca

Read transport.js and locate createError(), which the issue identifies as the place where request errors are wrapped. Preserve the original error code on the resulting error, then verify that timeout and other transport failures expose that code to callers.

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

Descrizione

feature-request

The problem
Request errors e.g. ETIMEDOUT don't have status or error code, would be nice to have so we can use them to open a circuit breaker or log out.

Suggested solution
Make transport.js add error code in createError()

createError(err, ctx) {
    const error = new Error(`Request failed for ${ctx.req.getMethod()} ${ctx.req.getUrl()}: ${err.message}`);
    error.code = err.code;
    return error;
  }

Local changes

Alternatives considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
We need to make timeout errors open our circuit breaker, as currently, we only open when we get 100+ 5xx errors. We do get the timeout error, but only as error object, with no error or status code which makes it hard to identify them, would be nice for request errors (e.g. timeout errors) to have error codes to identify them.

Lingua principale
JavaScript
Stelle
14
Fork
10
Merge medio
17h 13m
PR unite (30g)
1

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 bbc/http-transport

Tutte le issue di bbc/http-transport

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.