Repository navigation
Fix failed jobs polling forever: check for 'error' status, not 'failed' - #159
matthewberry wants to merge 5 commits into
Conversation
The backend reports failed jobs with phase 'error', but the results page checked for 'failed', so failed jobs polled forever and never showed the failure message.
945b2fd to
cece705
Compare
- Check for a terminal job status before parsing job_info, so a malformed or missing job_info on an errored job can't keep polling alive. - Wait 10s before retrying a failed status request instead of retrying immediately in a tight loop. - Type PollingResponseResult.status as JobStatus and replace the remaining hand-typed status strings. - Drop the unneeded 'as Job' cast in the results spec.
- ResultService: cap status retries at 5 consecutive failures so errors reach the subscriber instead of retrying forever. - ResultsComponent: show the failure message when status polling errors, stop polling and show it when the job id matches no job, and skip the sequence count when job_info is missing instead of throwing every poll. - ResultsComponent: read the job id from ActivatedRoute.paramMap instead of window.location, reloading on each id change since the router reuses the component between /results/:id URLs. Specs no longer depend on the Karma page URL.
|
Review follow-up, pushed as 0554a39. Each fix below has a spec that failed before the change and passes after it. Full suite: 17/17 passing. Reproduced and fixed
Checked, not a bug
Not addressed
Open questions
|
Job.phase is optional in the generated client and the `!` hid that. The backend also has a 'canceled' status the generated enum lacks, so a canceled job polled forever. Treat every phase other than queued and processing as final, and show the failure message unless it completed.
|
Follow-up on The backend (mmli-backend
Fix: any phase other than New specs cover a job with no phase and a Two related notes:
From the same backend read: for an unknown id, the list endpoint returns |
Closes #158.
Problem
The backend reports a failed job with phase
'error'(seeJobStatusin the generated client), but the results page checked for'failed'. When a job failed, the page kept pollingGET /clean/jobs/{id}every 10 seconds and never showed the failure message.Change
results.component.ts, the two status checks (stop polling, setfailedJob) now compare againstJobStatus.Errorinstead of'failed'. The'completed'check now usesJobStatus.Completed. Completed jobs are handled the same as before.PollingResponseStatus.statusis now typedJobStatusinstead ofstring. The results component is the only code that uses this type. With this type, a comparison against'failed'doesn't compile (TS2367).Testing
Added tests in
results.component.spec.ts. They use a stubbedResultServicewhose polling stream ends whengotEndResult()is called, like the real service:errorjob: polling stops,failedJobis set, results aren't fetched, and.failJobrenderscompletedjob: polling stops, results are fetched, and there's no failure messageprocessingjob: polling continuesnpx ng test --watch=false --browsers=ChromeHeadless: 9 of 9 pass on this branch, which is rebased ontomainafter #160. With the old'failed'checks restored, the error-job test fails.ng buildsucceeds. I didn't test against a real failed job in a browser.