Skip to content

fix(frontend): keep the computing-unit refresh and poll alive after a failed request - #8854

Merged
kunwp1 merged 4 commits into
apache:mainfrom
eugenegujing:fix/computing-unit-refresh-survives-errors
Oct 27, 2026
Merged

kunwp1 merged 4 commits into
apache:mainfrom
eugenegujing:fix/computing-unit-refresh-survives-errors

Conversation

@eugenegujing

@eugenegujing eugenegujing commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

ComputingUnitStatusService keeps 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: switchMap forwards 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 Subject with no subscriber left. The only trace was one ERROR HttpErrorResponse in the console; the UI showed nothing.

What users saw until they reloaded the page:

  • the dashboard's Computing Units list froze: units created elsewhere never appeared, terminated ones never disappeared;
  • the workspace's computing-unit dropdown stopped refreshing;
  • the selected unit's status never changed again, so the Failed / Terminating states from feat(computing-unit): surface failed/unhealthy computing units instead of an endless "Connecting" #7944 could not reach the UI;
  • the canvas run button could stay on "Connecting" after the socket was actually up, because its state is recomputed on poll emissions.

The change wraps the inner HTTP observable of both switchMaps in catchError(this.swallowFetchError(...)). The helper completes the failed fetch without emitting, which switchMap treats 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 with EMPTY rather 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 what HttpClient delivers 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's map(parseDashboardUnit) step, is a bug rather than an environment condition, so it is written to console.error with 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-unit requests and can make exactly one of them fail); it is not part of Texera.

Normal state: the dashboard requests the list once a second.

bug1-01-normal-list-refreshing-every-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.

bug1-02-one-injected-failure-no-requests-for-8s

From a second tab, a computing unit is terminated; that tab shows one unit immediately.

bug1-03-other-tab-unit-4-removed-shows-1-unit

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.

bug1-04-this-tab-frozen-87s-still-shows-2-units-BUG

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.

fixed-bug1-02-one-injected-failure-requests-keep-flowing-8-since

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.

fixed-bug1-03-unit-created-in-other-tab-appears-here fixed-bug1-04-unit-removed-in-other-tab-disappears-here-138-since-fail

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?

  • New unit tests in computing-unit-status.service.spec.ts, four in total, all red before the fix. Failures are modelled as HttpErrorResponse (status 500), which is what HttpClient delivers. keeps refreshing the list through failed fetches sends 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 fetch asserts that after a failed tick the selected unit object is untouched, the poll subscription is still open and stopPollingSelectedUnit was not called, and that the following four ticks all fetch and the next good result replaces the selection. logs a non-HTTP list failure ... and logs a non-HTTP poll failure ... feed a TypeError, then an HttpErrorResponse, then a success, and assert console.error is called exactly once, with the pipeline name and the TypeError, while the stream keeps going.
  • Mutation check, each mutation restored afterwards: removing the catchError from either pipeline, dropping the instanceof HttpErrorResponse check, or swapping the two pipeline labels each turns exactly the two tests for that pipeline or branch red. Replacing EMPTY with of(null) is a compile error, because the helper is typed Observable<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.
  • Spec file: 34 passed. Full frontend suite (ng test --watch=false): 231 files, 6447 passed, 1 skipped (pre-existing), 0 failed. prettier --check clean on both files.
  • Bug reproduced in a running local instance (screenshots above): Chrome against the Angular dev server and the local computing-unit managing service, with a page-level XMLHttpRequest wrapper 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.
  • Fixed build exercised in the same local instance (screenshots in the "After" section): after one injected failure the request counter kept increasing once a second (138 requests over the following two minutes), a unit created from another tab appeared within a second, and the same unit disappeared within a second after being terminated from the other tab. No reload. The logging branch does not change what the page does, so those screenshots still apply.

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.

… 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.
@github-actions github-actions Bot added fix frontend Changes related to the frontend GUI labels Oct 5, 2026
@Yicong-Huang Yicong-Huang added release/v1.3 back porting to release/v1.3 release/v1.2 back porting to release/v1.2 labels Oct 5, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 October 5, 2026 08:25
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
✅ release/v1.3 Already labeled — this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other.
✅ release/v1.2 Already labeled — this fix is queued to backport here. @xuang7 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other.

Auto-label run.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@eugenegujing

Copy link
Copy Markdown
Contributor Author

/request-review @kunwp1

@github-actions
github-actions Bot requested a review from kunwp1 October 6, 2026 01:14
@eugenegujing

Copy link
Copy Markdown
Contributor Author

@kunwp1 Could you please review this?

@kunwp1 kunwp1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

…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.
@kunwp1

kunwp1 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@mengw15 Can you approve this PR if there are no objections? Thanks!

@kunwp1
kunwp1 enabled auto-merge October 22, 2026 17:29
@codecov-commenter

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.67%. Comparing base (bc4f3c8) to head (f99afef).

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     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from dce6cf1
agent-service 99.16% <ø> (ø) Carriedforward from dce6cf1
amber 86.12% <ø> (-0.25%) ⬇️ Carriedforward from dce6cf1
computing-unit-managing-service 61.71% <ø> (-0.10%) ⬇️ Carriedforward from dce6cf1
config-service 87.50% <ø> (ø) Carriedforward from dce6cf1
file-service 82.29% <ø> (ø) Carriedforward from dce6cf1
frontend 96.92% <100.00%> (+0.40%) ⬆️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from dce6cf1
pyamber 98.54% <ø> (ø) Carriedforward from dce6cf1
workflow-compiling-service 72.61% <ø> (-1.65%) ⬇️ Carriedforward from dce6cf1

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kunwp1

kunwp1 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

This PR is blocked by @xuang7. @mengw15 Should we remove the release labels?

@xuang7 xuang7 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Removing release/v1.2: this is a long-standing issue with a page-reload workaround.

@xuang7 xuang7 removed the release/v1.2 back porting to release/v1.2 label Oct 27, 2026
@kunwp1
kunwp1 added this pull request to the merge queue Oct 27, 2026
Merged via the queue into apache:main with commit 65386d3 Oct 27, 2026
57 of 65 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened: draft #9164 (#9164) to release/v1.3, assigned to @eugenegujing — needs manual work because the backported tree failed its pre-merge build.

mengw15 pushed a commit to PG1204/texera that referenced this pull request Oct 29, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix frontend Changes related to the frontend GUI release/v1.3 back porting to release/v1.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

one failed request permanently stops the computing-unit list refresh and the selected-unit poll

6 participants