[ZEPPELIN-6565] Re-enter Angular zone for React remote callbacks - #5417
Conversation
voidmatcha
left a comment
There was a problem hiding this comment.
LGTM 👍
Future host callbacks should follow the same zone-handling pattern.
tbonelee
left a comment
There was a problem hiding this comment.
LGTM, approving.
Verified on a running dev server: Zone.current was <root> inside onError every run, so the diagnosis holds and the directive is the right place to wrap it.
One correction on the rationale, not on the patch. The issue, and the existing reportError comment, both say a markForCheck() from outside the zone has "nothing to flush it". That is not true on Angular 18+, where hybrid scheduling schedules a tick for exactly that case: the fallback rendered 1 to 4 ms after onError. The fix still stands, just for a different reason, that async work a host handler starts stays untracked by NgZone without ngZone.run().
Nothing to do on your side. I will fix that comment, since it is mine (from 52a638e), and note the correction on the issue.
|
Merged into master |
What is this PR for?
This PR fixes
ReactMountDirectiveso callbacks invoked by a mounted React remote re-enter the Angular zone before calling back into the Angular host.ReactMountDirectivemounts and updates React remotes insidengZone.runOutsideAngular(). The directive already usedngZone.run()for errors reported through its ownreportError()path, but props were passed to the remote unchanged. As a result, a remote such as the React paragraph footer could callprops.onError()directly from outside the Angular zone.For an Angular
OnPushhost component, that can mark the component dirty without scheduling change detection, delaying the fallback UI until some later zone-scheduled work occurs.This change wraps host callbacks as props enter
ReactMountDirective, while keeping the original props (latestRawProps) available for directive-internal error reporting. The wrapped props (latestProps) are passed to bothmount()andupdate(), so React remote callbacks consistently run through the Angular zone boundary.What type of PR is it?
Bug Fix
What is the Jira issue?
How should this be tested?
Run the shell unit tests:
cd zeppelin-web-angular npm run test:shellQuestions: