Repository navigation
fix(frontend): keep the computing-unit refresh and poll alive after a failed request - #8854
Conversation
… failed request Wrap the inner HTTP observable of both switchMaps in ComputingUnitStatusService with catchError(() => EMPTY), so a failed list fetch or selected-unit poll ends only that request instead of terminating the stream. Add spec tests for a failed fetch followed by successful ones on both pipelines.
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
|
/request-review @kunwp1 |
|
@kunwp1 Could you please review this? |
…dropping them silently Replace the two inline `catchError(() => EMPTY)` in ComputingUnitStatusService with a `swallowFetchError(pipeline)` helper that still returns EMPTY but writes a console.error for any error that is not an HttpErrorResponse, so a bug in the response mapping stays visible while HTTP failures remain silent. In the spec, merge the three list tests into one and the two poll tests into one, model the failures as HttpErrorResponse instead of a plain Error, and add one test per pipeline for the logged versus silent branches.
|
@mengw15 Can you approve this PR if there are no objections? Thanks! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8854 +/- ##
============================================
+ Coverage 91.95% 92.67% +0.72%
+ Complexity 5081 5058 -23
============================================
Files 1280 1278 -2
Lines 55622 62758 +7136
Branches 7048 8769 +1721
============================================
+ Hits 51147 58162 +7015
- Misses 2733 2803 +70
- Partials 1742 1793 +51
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Backport PR opened: draft #9164 (#9164) to |
…fter a failed request (apache#9164) ### What changes were proposed in this PR? Automated backport of apache#8854 to `release/v1.3`. Source: 65386d3 · [automation run](https://github.com/apache/texera/actions/runs/40445450117) ### Any related issues, documentation, discussions? Backport of apache#8854. Originally linked apache#8850. ### How was this PR tested? Release-branch CI runs on this branch once the build is fixed and this PR is marked ready for review. ### Was this PR authored or co-authored using generative AI tooling? No. Co-authored-by: Eugene Gu <[email protected]> Co-authored-by: Kunwoo (Chris) <[email protected]>
What changes were proposed in this PR?
ComputingUnitStatusServicekeeps the computing-unit list and the selected unit's status fresh through two RxJS pipelines: the list refresh (refreshComputingUnitListSignal → switchMap(listComputingUnits) → subscribe) and the selected-unit poll (interval(2000) → switchMap(getComputingUnit) → subscribe). Neither inner HTTP observable had any error handling. In RxJS an error is a terminal notification:switchMapforwards an inner error downstream unchanged, and a subscriber that receives it is closed for good. Both subscriptions are created once, in the constructor of this root-provided service, and nothing ever re-creates them.So a single failed request (a 500, a 502/504 from the proxy while the computing-unit managing service restarts, a network blip) killed the pipeline for the rest of the page's life. The refresh signal kept being pushed every second by the dashboard, into a
Subjectwith no subscriber left. The only trace was oneERROR HttpErrorResponsein the console; the UI showed nothing.What users saw until they reloaded the page:
The change wraps the inner HTTP observable of both
switchMaps incatchError(this.swallowFetchError(...)). The helper completes the failed fetch without emitting, whichswitchMaptreats as "this round is over, wait for the next signal"; the stream stays subscribed and the next refresh signal or poll tick fetches again. Completing withEMPTYrather than an empty list keeps the cached list and the selected unit untouched during the failed round, so nothing flickers.The helper distinguishes two kinds of failure. An
HttpErrorResponse, which is whatHttpClientdelivers for every transport-level failure (non-2xx status, dropped connection, timeout, unparsable body) and what both app interceptors rethrow, is dropped without logging: it is expected while the backend is unavailable, it would otherwise print once a second during a restart, and the failed requests remain visible in the browser's Network panel. Anything else, for example an exception thrown inside the managing service'smap(parseDashboardUnit)step, is a bug rather than an environment condition, so it is written toconsole.errorwith the pipeline name before being dropped. Before this PR such a bug surfaced once as an uncaught error and then froze the page; now it is reported on every tick and the page keeps working.Before: one failed request freezes the dashboard
The black panel in the top-right corner is a debugging overlay injected into the page for the reproduction (it counts
GET api/computing-unitrequests and can make exactly one of them fail); it is not part of Texera.Normal state: the dashboard requests the list once a second.
One request is made to fail. Eight seconds later no further request has been sent, although the page still asks for a refresh every second.
From a second tab, a computing unit is terminated; that tab shows one unit immediately.
87 seconds after the failure the first tab still shows two units and has sent no request. Reloading the page restores the list at once, so the backend was healthy the whole time.
After: the same failure, on this branch
Same page, same overlay, served from this branch. One request (45) is made to fail; eight seconds later eight more requests have gone out and the list is still refreshing.
A unit created from a second tab appears on this page within a second (78 requests since the failure), and disappears again when it is terminated from the other tab (138 requests since the failure), all without a reload.
Any related issues, documentation, discussions?
Closes #8850
Related follow-ups that depend on this fix landing first (not part of this PR): a selected unit whose pod vanishes polls back to Pending forever, and dropdown rows do not refresh while the dropdown is open. Both of their fixes call
refreshComputingUnitList(), which only works if this pipeline is alive.How was this PR tested?
computing-unit-status.service.spec.ts, four in total, all red before the fix. Failures are modelled asHttpErrorResponse(status 500), which is whatHttpClientdelivers.keeps refreshing the list through failed fetchessends two failures then a success and asserts three fetches, no list emission for a failure, and the good list on the next success.keeps polling the selected unit through a failed fetchasserts that after a failed tick the selected unit object is untouched, the poll subscription is still open andstopPollingSelectedUnitwas not called, and that the following four ticks all fetch and the next good result replaces the selection.logs a non-HTTP list failure ...andlogs a non-HTTP poll failure ...feed aTypeError, then anHttpErrorResponse, then a success, and assertconsole.erroris called exactly once, with the pipeline name and theTypeError, while the stream keeps going.catchErrorfrom either pipeline, dropping theinstanceof HttpErrorResponsecheck, or swapping the two pipeline labels each turns exactly the two tests for that pipeline or branch red. ReplacingEMPTYwithof(null)is a compile error, because the helper is typedObservable<never>; with the type loosened to let it compile, it turns three tests red, the two survival tests through their emission-count and selection assertions and the poll logging test.ng test --watch=false): 231 files, 6447 passed, 1 skipped (pre-existing), 0 failed.prettier --checkclean on both files.XMLHttpRequestwrapper that fails exactly one list request. Reproducible without instrumentation by stopping the computing-unit managing service for a few seconds while the dashboard's Compute page is open, starting it again, and changing a unit from another tab.Was this PR authored or co-authored using generative AI tooling?
Yes. Generated-by: Claude Code (claude-fable-5-1). Co-authored with Claude; the author reviewed the change before submission.