Command Palette

Search for a command to run...

Hectal
Phase 3: Stop, Retry and Failure
AI Frontend · Exercise 5 of 5 Previous
Advanced

Retry Only What Can Work

Write askWithRetry(). The route fails with 503 twice and then answers. #ask should show the answer in #answer and the number of requests it took in #attempts as Attempts: 3.

Retry only retryable failures (408, 429 and 5xx), at most 3 retries, waiting 100 * 2 ** attempt ms before each retry. #bad asks a question the route rejects with 400: it must not be retried. Show Mitra could not answer. in #error and Attempts: 1.

What Check tests

  1. #ask retries the two 503s and shows the answer and Attempts: 3
  2. #bad is not retried: Attempts: 1 and the error message
  3. The code waits between tries (it uses sleep)

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.