fix: implement resilient POST client for replay job submission#319
Merged
codeZe-us merged 1 commit intoJul 16, 2026
Merged
Conversation
Replace the mock-replay-submitter stub with a real HTTP client wrapper around native fetch. Sets Content-Type/Accept: application/json to satisfy Fastify's payload handling, checks Response.ok before trusting the body, safely parses the JSON reply, and extracts jobId - throwing descriptive errors for non-2xx responses or a missing jobId instead of letting network failures (DNS, connection refused, downtime) surface as unhandled Promise rejections that crash the process. Fixes Toolbox-Lab#313 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
codeZe-us
self-requested a review
July 16, 2026 22:19
codeZe-us
approved these changes
Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
examples/api-clients/mock-replay-submitter/index.jsscript, previously a one-line stub, as a resilient HTTP client wrapper around nativefetch.Content-Type: application/jsonandAccept: application/jsonheaders on the POST tohttp://localhost:3001/api/replay(overridable viaAPI_URLenv var, consistent with the siblingwebsocket-clientexample).Response.okbefore trusting the body, safely parsesResponse.json(), and extractsjobId, throwing a descriptive error for non-2xx responses (including 500) or a response missingjobId.Test plan
Verified locally against
apps/server(pnpm --filter grat-server dev):tx-hashargument → usage message, exit code 1.500response → descriptiveHTTP 500 ... : temporary test failureerror, exit code 1.jobIdin body (current state ofPOST /api/replay, which only returns{ status: "queued" }) → descriptive "response did not include a jobId" error, exit code 1.Note:
apps/server'sPOST /api/replayhandler currently returns{ status: "queued" }with nojobIdfield at all (it's a scaffold/stub, out of scope for this issue per the "Files location" in #313). Once that route is implemented to actually return ajobId, this client will pick it up correctly with no changes needed — confirmed by testing against a temporarily-patched local route.Fixes #313
🤖 Generated with Claude Code