Skip to content

Fix SSE events running outside the Angular zone - #197

Merged
juliusvonkohout merged 2 commits into
kserve:masterfrom
LogicalGuy77:fix-ui
Aug 10, 2026
Merged

Fix SSE events running outside the Angular zone#197
juliusvonkohout merged 2 commits into
kserve:masterfrom
LogicalGuy77:fix-ui

Conversation

@LogicalGuy77

Copy link
Copy Markdown
Contributor
  1. Clicking on an inference service, didn't show the details page. It was only visible once we reloaded it
issue1

Signed-off-by: Harshit Nayan <harshitacademia@gmail.com>
@juliusvonkohout
juliusvonkohout requested a balanced review from Copilot August 6, 2026 18:01

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (2)

frontend/src/app/services/sse.service.ts:75

  • The primary regression fix is untested: the service test only updates constructor setup and still exercises URL encoding. Add a test that invokes the mocked EventSource callback outside Angular's zone and verifies that subscriber delivery occurs through NgZone.run; cover the error callbacks as well so a later refactor cannot silently restore the stale-view behavior.
          this.zone.run(() => observer.next(data));

frontend/src/app/services/sse.service.ts:16

  • zone is ambiguous and less expressive than the injected dependency's role. Rename this field to angularZone and update its references so readers can distinguish Angular execution context from other meanings of “zone.”
  constructor(private zone: NgZone) {}

Rename the injected NgZone field to angularZone for clarity, and add
tests that fire the mocked EventSource message and error callbacks from
outside the Angular zone, asserting subscribers receive them inside the
zone via NgZone.isInAngularZone(). Covers parse errors, connection
errors, and reconnect exhaustion so removing the NgZone.run wrapper
would fail the suite.

Signed-off-by: Harshit Nayan <harshitacademia@gmail.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@danish9039

Copy link
Copy Markdown
Contributor

@LogicalGuy77 we have fixed similar issue in #194 , did you confirmed that issue still exists by reproducing it against current master ??

@LogicalGuy77

LogicalGuy77 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

yes, I tested it against the current master

cc @danish9039

@LogicalGuy77

Copy link
Copy Markdown
Contributor Author

#194 fixed the most visible instance of that symptom at the navigation layer: in Dashboard-connected mode it bypasses Angular routing and performs a full page load of the details URL, which reboots the application and guarantees a fresh render. That works and is still compatible with this change, but it only covers the row-click path. Any other interaction on DOM rendered from an SSE event like button clicks, menu actions, future features has the same latent problem, and each would need its own workaround.

This PR fixes the defect at its source: SSE emissions are re-entered into the Angular zone via NgZone.run(), so change detection runs after every SSE-driven render and event listeners are registered inside the zone.

Once this merges, the Dashboard-connected page-load path added in #194 should no longer be necessary, since the stale-render condition it worked around is fixed at the source.

@juliusvonkohout

Copy link
Copy Markdown
Contributor

Thank you, Please raise a follow up PR then

@juliusvonkohout
juliusvonkohout merged commit 2d8ec7d into kserve:master Aug 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants