Repository navigation
Description
A failed mutation is sent twice, ~1s apart, even when the failure is a 404 — a status the app's own retry policy lists as non-retryable.
Evidence
scripts/audit/smoke-move-undo.mjs, one stage move, real session:
+18901ms PATCH applications/d95a852c-... {"status":"reviewing"}
↳ 404 {"error":"Not Found","message":"Application not found"}
+19996ms PATCH applications/d95a852c-... {"status":"reviewing"}
↳ 404 {"error":"Not Found","message":"Application not found"}
One user action. Two identical writes, 1,095ms apart — react-query's first retry backoff.
What should have stopped it
packages/scf-core/provider/react-query/QueryProvider.tsx:38
mutations: {
retry: (failureCount, error) => shouldRetry(failureCount, error, 1),
},packages/scf-core/provider/react-query/retry.ts:17,37
const NON_RETRYABLE_STATUSES = new Set([400, 401, 403, 404, 409, 422])
export function shouldRetry(failureCount, error, maxRetries) {
const statusCode = statusCodeOf(error)
if (statusCode !== undefined && NON_RETRYABLE_STATUSES.has(statusCode)) return false
return failureCount < maxRetries
}404 is in the set, so this should return false on the first failure and no retry should happen. It retried anyway.
The likely cause
statusCodeOf reads error.statusCode. The SDK's NotFoundError does set it (packages/sdk/src/http/errors.ts:37 → super(message, 404, 'not_found')), so the property exists in source. Two candidates for why the policy does not see it:
@scaffald/sdkresolves to a staledist. The SDK is a submodule built to a gitignoreddist; if the built copy predates thestatusCodeplumbing, the thrown error is a plainErrorandstatusCodeOfreturnsundefined— which falls through tofailureCount < maxRetriesand retries.- The error is wrapped before react-query sees it. Anything that re-throws as a bare
ErrorlosesstatusCodethe same way.
Worth confirming which before fixing — the difference decides whether the fix is a rebuild, a build-freshness guard, or a change to how errors propagate.
Why it matters
A retried non-idempotent write is a correctness risk, not just noise. It is harmless here only because the endpoint 404s (#646) so neither attempt does anything. Against a working endpoint this is a double write on every transient failure the policy was specifically written to stop retrying — and #579 shows the cost of getting this predicate wrong in the other direction (a 401 burning the whole retry budget in 3s).
Acceptance
- Determine whether the runtime error carries
statusCode; if not, why not. - A 404 (and every status in
NON_RETRYABLE_STATUSES) produces exactly one request from one mutation. - A test asserts the predicate against a real SDK-thrown error, not a hand-built
{ statusCode }object — a unit test onshouldRetryalone would pass today while the app misbehaves.
Related
- fix(ats): moving a candidate 404s — PATCH /v1/employer/applications/{id} rejects rows the list returns #646 — the 404 that exposed this
- The delayed-write change for feat(ats): stage-move toast — and why Undo cannot mean "move it back" #643, whose wire-level smoke caught it
- fix(profile): every profile editor loads empty — first-load reads 401 and are never retried #579 — the earlier retry-policy fix this predicate came from
Activity
feat(ats): a stage move can be undone, because it has not been sent y…
fix(api): an org admin passed both auth checks and then 404'd anyway (#…
thinkclay commentedon Aug 25, 2026
The reproduction is gone, but the question is not. Reopening context rather than closing.
#646 is fixed (#649,
63c85be63). The endpoint now returns 200, and with it the duplicate write disappears:That confirms the second request was the client retrying the failure — this was a symptom of #646, not an independent double-send. Which lowers the urgency but does not answer the actual question filed here:
That predicate is still wrong, or the error reaching it still lacks
statusCode. It just no longer has a convenient way to reproduce through the ATS board, since that path succeeds now.Suggested next step for whoever picks this up: force a 404 from any SDK-backed mutation (a deleted id works) and count the requests. If it sends two, the predicate is not seeing
statusCodeand the two candidates in the body above still apply — stale@scaffald/sdkdist, or an error re-thrown as a bareError.The acceptance criterion stands, including the note that a unit test on
shouldRetryalone would pass today while the app misbehaves.test(net): pin the retry policy against errors the SDK really throws (#…
thinkclay commentedon Aug 27, 2026
Recording why this closed, since the title still asserts something untrue.
The premise does not hold. I filed this after seeing two identical PATCHes 1,095ms apart; retry was the obvious explanation. It is not the explanation:
distcarriesstatusCodedist/index.js:54NotFoundError,statusCode: 404statusCodeOf(err)404shouldRetry(0, err, 1)falseretrydefault, against a real SDK 404That last check exists because the first four only test pieces in isolation. It rules out both candidate causes in the original body — stale
dist, and the error being re-wrapped as a bareError.The duplicate was real and timestamped, but it was not a retry, and it no longer reproduces now that #649 stopped the endpoint 404ing. I could not identify what sent it. That is unsatisfying, but "the retry policy is broken" is not supported, and leaving it open would send someone to fix a predicate that works.
If it recurs it will not go unnoticed:
smoke-move-undo.mjsnow pins exactly one write, 2xx per move.Kept — acceptance criterion 3, which was right. The existing tests used a hand-built
{ statusCode }object, which cannot notice a real SDK error losing its status. The assertions now also run againstNotFoundError,AuthenticationError,RateLimitErrorandAPIErroras the SDK constructs them (#650).