Repository navigation
fix(mothership): pass typed fork refusals through and stop overlapping retries - #8564
waleedlatif1 wants to merge 6 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
The route passes a worker 409 or 413 through with a message the person can act on, but the fork action replaced every failure with "Failed to fork chat". It now shows the refusal's message for those two statuses. The per-attempt timeout's comment no longer claims it sits above a 30 s worker budget: that budget bounds each statement, not the copy. A timed-out attempt leaves nothing behind because the worker rolls back a copy whose caller has gone (mothership#575).
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
|
Closing in favour of one consolidated fork PR (paired with the worker change) that carries these fixes together with the remaining fork gaps. |
Summary
/api/chats/fork.copyWorkerConversationturned every non-2xx into a genericError, so the route answered 500 even when the worker refused for a reason the caller can act on: the chat is gone (404), the selected response hasn't finished (409), or the conversation is too long to fork (413).catchswallowed the first attempt's thrown error, so a 400, a 500, a malformed receipt and a 15 s timeout were all retried. A slow fork that hit the 15 s per-attempt timeout was sent again while the worker was still copying the first one.OrchestrationError('not_found'), 409 →conflict, 413 →payload_too_large. The route passes those through as 404/409/413 with a caller-facing message. The existing not_found/forbidden → 404 and validation → 400 mappings are unchanged.isRetryableNetworkError: a refused, reset, dropped or unreachable connection anywhere in the cause chain) and 502/503/504 get one more attempt.EHOSTUNREACHjoins the shared classifier's codes, because it is a connection that never opened. Everything else, including a timed-out attempt, fails at once. A timeout may mean the worker is still copying.Behaviour changes
POST /api/mothership/chats/[chatId]/forkcan now return 409 and 413, besides the existing 400/401/404/500. The body shape is the same{ error }used by its other error responses. The success response and the route contract are unchanged.Type of Change
Testing
origin/staging(9 tests), each green now:fork-worker.test.ts: 404/409/413 classified with one request, 500/400 not repeated, a timed-out attempt not repeated, and a 404 whose body fails to cancel still classified (added in review). These tests drive a fake worker that records the fork requests it receives and assert on those, not on mock calls.fork/route.test.ts: worker 404/409/413 passed through as the response status.TypeErrormakes the non-socketTypeErrortest red.EHOSTUNREACHmakes its retry test red.type-check,bun run lint,check:api-validation:strictandcheck:audits(58), all passing. It is a rendered-message change, so it has no unit test.vitest run lib/mothership/chat app/api/mothership: 44 files, 573 tests pass.bun run lint,apps/simtype-check,bun run check:audits(57 audits) andbun run check:api-validation:strictall pass.Checklist
test-auditauthoring gate)