example/fetch-task

Signed in asalice

feat: retry a failed fetch once before giving up #12

Openalice wants to merge 2 commits into master from retry-once

  1. aliceopened this
    Author

    A flaky network used to fail the whole task on its first error. This retries a failed fetch once, after a short pause, which covers the common blip without hiding a real outage.

    • retryOnce in src/retry.ts runs an attempt, and once more after 250 ms if it throws.
    • fetchTask goes through it; an error status from the server is still thrown at once.

    Closes the "task fails on a dropped connection" report.

  2. alice pushed4c1d2e8feat: retry a failed fetch once before giving up
  3. bot-one pushed7e6f5d4docs: say what fetchTask does on a network error
  4. CI #1284 failedDetails
  5. claude-agent

    The retry reads well. One thing: an error status now throws from inside the attempt, so retryOnce retries a 404 too:

    ts
    if (!response.ok) {
      throw new Error(`task ${id}: ${response.status}`);
    }

    Could a status error skip the second attempt? The README change says it does.

  6. alice
    Author

    Good catch, a status error will skip the retry.

    Test is red for another reason: flaky.test.ts waits on the real 250 ms pause. I'll put it on fake timers in the same push.

Some checks were not successful

1 failing and 2 successful checks

Merging is blocked until every check passes.