-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expressions service fixes: better error and loading states handling #51183
Expressions service fixes: better error and loading states handling #51183
Conversation
💔 Build Failed
|
f7730c3
to
88a753a
Compare
Pinging @elastic/kibana-app-arch (Team:AppArch) |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
prettier remove error$ and errorRenderer, use onRenderError callback instead for both use custom error handler only if it is provided by consumer, otherwise fallback to default handler add comment fix linter issues fix
move utilities to kibana_react/util
d814bd0
to
21d8c9c
Compare
renderError ? ( | ||
renderError(state.error.message) | ||
) : ( | ||
<div data-test-subj="expression-renderer-error">{state.error.message}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Default error state now fallbacks to default of
render.ts
which is toast from notification service - If user of this react component provided
renderError
function, then the component itself will handle the error and will render the error component returned from renderError()
💚 Build Succeeded |
@elasticmachine merge upstream |
@@ -64,9 +72,14 @@ export class ExpressionLoader { | |||
this.render(data); | |||
}); | |||
|
|||
this.render$.subscribe(() => { | |||
this.loadingSubject.next(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we emitting false now after loading has completed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I left the public observable the same,
This is done due to:
this.loading$ = this.loadingSubject.asObservable().pipe(
filter(_ => _ === true),
map(() => void 0)
);
// as loading$ could emit straight away in the constructor | ||
// and we want to notify subscribers about it, but all subscriptions will happen later | ||
this.loading$ = this.loadingSubject.asObservable().pipe( | ||
filter(_ => _ === true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please explain why we need boolean observable, where we then filter out all the falses and map trues to void ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention was to leave public api (loading$) unchanged in this pr and just fix the bug where expression_renderer.tsx
was missing initial loading state. This was fixed by changing Subject to BehaviourSubject to remember last emitted value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it's changing the default behavior of the error handler when the expression fails to render. Try going to Lens and configuring only a Y axis.
expect(instance.find(EuiProgress)).toHaveLength(0); | ||
}); | ||
|
||
it('should display an error message when the expression fails', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've changed the behavior this test was testing- why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default error handling of expression_renderer.tsx
now fallbacks to default error handling of render.ts
. This was done primarily to reduce number of code paths to support.
Pls see: https://github.com/elastic/kibana/pull/51183/files#r349611820
And that is why test was deleted as we have less code paths in this component.
This looks like it's changing the default behavior of the error handler when the expression fails to render. Try going to Lens and configuring only a Y axis.
I guess I indeed missing the change, where I had to explicitly override error handling, where previous default of expression_renderer.tsx
was expected.
I found one missing place here: x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/expression_wrapper.tsx
and added error override, but as I understand this is for dashboard page?
9a3282f
Any other places I am missing?
Try going to Lens and configuring only a Y axis.
I am likely doing it wrong, but I think I am getting the same behaviour as in master. Blank screen. Any suggestions?
…sion-service-render-swallows-errors
…thub.com:Dosant/kibana into bugfix/expression-service-render-swallows-errors
💚 Build Succeeded |
…sion-service-render-swallows-errors # Conflicts: # src/plugins/expressions/public/render.ts
💔 Build Failed |
💔 Build Failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong about the state of master, this is not changing the behavior. LGTM
💚 Build Succeeded |
@elasticmachine merge upstream |
💚 Build Succeeded |
…lastic#51183) 1. This pr fixes regression in v7.6 - elastic#51153. Visualisation which are using ExpressionLoader directly are swallowing render errors in 7.6, because generic error handling is happening only on expression_renderer.tsx level (react component wrapper around renderer). Now react agnostic render code render.ts, loader.ts: has it's own default error handler which is toast from notification service. It also allows to pass custom error handler instead of default one React expression renderer expression_renderer.tsx: if consumer wants to render error as react component inline, then the component uses custom error handler from render.ts to wire up react component. 2. This pr fixes issue of loader.ts where initial loading$ was not emitted Had to change loadingSubject from Subject to BehaviorSubject to remember the last value 3. This pr fixes dependencies in effects of expression_renderer.tsx # Conflicts: # src/plugins/expressions/public/loader.test.ts
…51183) (#51800) 1. This pr fixes regression in v7.6 - #51153. Visualisation which are using ExpressionLoader directly are swallowing render errors in 7.6, because generic error handling is happening only on expression_renderer.tsx level (react component wrapper around renderer). Now react agnostic render code render.ts, loader.ts: has it's own default error handler which is toast from notification service. It also allows to pass custom error handler instead of default one React expression renderer expression_renderer.tsx: if consumer wants to render error as react component inline, then the component uses custom error handler from render.ts to wire up react component. 2. This pr fixes issue of loader.ts where initial loading$ was not emitted Had to change loadingSubject from Subject to BehaviorSubject to remember the last value 3. This pr fixes dependencies in effects of expression_renderer.tsx # Conflicts: # src/plugins/expressions/public/loader.test.ts
* upstream/7.x: Fix infinite redirect loop when multiple cookies are sent (elastic#50452) (elastic#51821) [Console] Proxy fallback (elastic#50185) (elastic#51814) Added endgame-* index and new heading 3 Elastic Endpoint SMP. (elastic#51071) (elastic#51828) [Maps] Added options to disable zoom, hide tool tips, widgets/overlays in embeddable maps (elastic#50663) (elastic#51811) Move errors and validate index pattern ⇒ NP (elastic#51805) (elastic#51831) [SIEM][Detection Engine] Adds ecs threat properties to rules (elastic#51782) (elastic#51827) [Lens] Remove client-side reference to server source code (elastic#51763) (elastic#51825) fixes drag and drop in tests (elastic#51806) (elastic#51813) [Uptime] Redesign/44541 new monitor list expanded row (elastic#46567) (elastic#51809) [7.x] [Telemetry] collector set to np (elastic#51618) (elastic#51787) [Uptime] added test for chart wrapper (elastic#50399) (elastic#51808) Expressions service fixes: better error and loading states handling (elastic#51183) (elastic#51800) Query String(Bar) Input - cleanup (elastic#51598) (elastic#51804) [ML] Adjust and re-enable categorization advanced wizard test (elastic#51005) (elastic#51017) fixes url state tests (elastic#51746) (elastic#51798) fixes browser field tests (elastic#51738) (elastic#51799) [Task Manager] Tests for the ability to run tasks of varying durations in parallel (elastic#51572) (elastic#51701) [ML] Fix anomaly detection test suite (elastic#51712) (elastic#51795) [SIEM] Fix Timeline drag and drop behavior (elastic#51558) (elastic#51793)
…ra/kibana into IS-46410_remove-@kbn/ui-framework * 'IS-46410_remove-@kbn/ui-framework' of github.com:mbondyra/kibana: (49 commits) [ML] Re-activate after method in transform test (elastic#51815) [SIEM] [Detection Engine] Add edit on rule creation (elastic#51670) De-angularize visLegend (elastic#50613) [SIEM][Detection Engine] Change security model to use SIEM permissions [Monitoring] Sass cleanup (elastic#51100) Move errors and validate index pattern ⇒ NP (elastic#51805) fixes pagination tests (elastic#51822) Split legacy plugin discovery, expose SavedObjects scopedClient, wrappers, repository (elastic#48882) [SIEM][Detection Engine] Adds ecs threat properties to rules (elastic#51782) [Lens] Remove client-side reference to server source code (elastic#51763) Fix infinite redirect loop when multiple cookies are sent (elastic#50452) fixes drag and drop in tests (elastic#51806) [Console] Proxy fallback (elastic#50185) Query String(Bar) Input - cleanup (elastic#51598) shim visualizations plugin (elastic#50624) Expressions service fixes: better error and loading states handling (elastic#51183) fixes url state tests (elastic#51746) fixes browser field tests (elastic#51738) [ML] Fix anomaly detection test suite (elastic#51712) [SIEM] Fix Timeline drag and drop behavior (elastic#51558) ...
Summary
1. This pr fixes regression in v7.6 - #51153.
Visualisation which are using ExpressionLoader directly are swallowing render errors in 7.6, because generic error handling is happening only on
expression_renderer.tsx
level (react component wrapper around renderer).Now react agnostic render code
render.ts
,loader.ts
:React expression renderer
expression_renderer.tsx
:render.ts
to wire up react component.The pr also adds unsubscribes from ExpressionLoader observable in
expression_renderer.tsx
2. This pr fixes issue of
loader.ts
where initial loading$ was not emittedHad to change loadingSubject from Subject to BehaviorSubject to remember the last value
3. This pr fixes dependencies in effects of
expression_renderer.tsx
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers