Skip to content

test(net): pin the retry policy against errors the SDK really throws - #650

Merged
thinkclay merged 1 commit into
mainfrom
fix/retry-404
Aug 27, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/retry-404

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Closes #647 — the premise was wrong, and this keeps the half of it that was right.

What #647 claimed

That a 404 mutation was being retried, despite 404 sitting in NON_RETRYABLE_STATUSES. I filed it after seeing two identical PATCHes 1,095ms apart on the wire.

What I actually found

check result
SDK's built dist carries statusCode yes — dist/index.js:54
a real 404 through the SDK NotFoundError, statusCode: 404
statusCodeOf(err) 404
shouldRetry(0, err, 1) false
react-query's own mutation machinery, driven with the app's exact retry default, against a real SDK 404 1 PATCH, not 2

The predicate is correct at the unit level and in composition. I built the last one specifically because the first four only test pieces — I'd already been burned this session by reasoning about components that were each individually fine.

So the duplicate write was real and timestamped, but retry was not its cause, and it no longer reproduces now that #649 stopped the endpoint 404ing. I could not identify what did send it. That's an unsatisfying end, but "the retry policy is broken" is not supported and leaving the issue open would send someone to fix a predicate that works.

The regression guard for a recurrence already exists: smoke-move-undo.mjs now pins exactly one write, 2xx per move, so a genuine double-send fails the smoke rather than going unnoticed.

What was worth keeping

#647's third acceptance criterion, which was correct:

a unit test on shouldRetry alone would pass today while the app misbehaves

The existing tests build a hand-rolled { statusCode } object. That tests the arithmetic and nothing else — it cannot notice if a real SDK error stops carrying statusCode, which is exactly the silent failure #647 hypothesised.

So the assertions now also run against NotFoundError, AuthenticationError, RateLimitError and APIError as the SDK constructs them. If the SDK renames the field, drops it from a subclass, or its build output falls behind its source, these fail while the hand-built ones keep passing.

No production change — nothing was broken. 20/20 tests pass, scf-core typechecks clean.

🤖 Generated with Claude Code

#647 reported that a 404 was being retried despite 404 sitting in
NON_RETRYABLE_STATUSES. Investigating it, the premise does not hold — but the
report's third acceptance criterion was right and is worth keeping.

What was actually checked:

  the SDK's built dist carries statusCode          yes (dist/index.js:54)
  a real 404 through the SDK                       NotFoundError, statusCode 404
  statusCodeOf on that error                       404
  shouldRetry(0, error, 1)                         false
  react-query's own mutation machinery, driven
    with the app's exact retry default, against
    a real SDK 404                                 1 PATCH, not 2

So the predicate is correct at the unit level AND in composition. The duplicate
write observed in #647 was real and timestamped, but retry was not its cause,
and it no longer reproduces now that #646 stopped the endpoint 404ing.

The existing tests here build a hand-rolled `{ statusCode }` object. That
tests the arithmetic and nothing else — it cannot notice if a real SDK error
stops carrying `statusCode`, which is the part that would break silently and
the exact failure mode #647 hypothesised. #647's own acceptance criterion said
as much:

  "a unit test on shouldRetry alone would pass today while the app misbehaves"

So the assertions are repeated against NotFoundError, AuthenticationError,
RateLimitError and APIError as the SDK constructs them. If the SDK renames the
field, drops it from a subclass, or its build output falls behind its source,
these fail while the hand-built ones keep passing.

No production change: nothing was broken.

Co-Authored-By: Claude Opus 5 <[email protected]>
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

Successfully merging this pull request may close these issues.

fix(net): a 404 mutation is retried, though 404 is in NON_RETRYABLE_STATUSES

1 participant