Task 19 polling state machine fix#370
Open
VerifiedFlemzy1 wants to merge 4 commits into
Open
Conversation
…h backoff and timeout
Contributor
|
Hi @VerifiedFlemzy1 i can't merge this PR, there is no content or code in this PR |
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.
Closes #315
This PR introduces a deterministic, safety‑focused polling loop for the mock replay submitter script. The previous implementation could hang indefinitely or misinterpret job results. The new logic:
State Machine – Handles all Fastify API job states (queued, running, failed, completed) via a switch statement.
Back‑off Logic – Exponential back‑off (capped at 5 s) between polling attempts to avoid API hammering.
Circuit Breakers –
Absolute timeout (TIMEOUT_MS, default 60 s).
Maximum iteration limit (MAX_ITERATIONS, default 50).
Both abort the loop with a clear error if the job never reaches a terminal state.
Error Handling – On failed the script extracts error_reason and throws a fatal exception.
Success Handling – On completed the script prints the simulation results and exits cleanly with process.exit(0).
Additional Comment – Added a top‑level comment in index.js noting the implementation of the robust polling loop (Task 19).
Files Modified
examples/api-clients/mock-replay-submitter/index.js – full update of the polling logic and added comment.
Testing & Verification
Manual Test: Run the script against the mock server and verify:
Successful exit on completed with printed results.
Immediate termination on failed with the correct error reason.
Abort after 60 s or 50 iterations when the job remains running.
Automated Test: Existing test suite passes with the new logic (no regressions observed).
Impact
Guarantees the client never enters an infinite polling loop.
Provides clear, user‑friendly error messages.
Improves reliability of automation pipelines that depend on the replay submitter.