-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Dashboard] Fix alias redirect & update error handling #159742
[Dashboard] Fix alias redirect & update error handling #159742
Conversation
Pinging @elastic/kibana-presentation (Team:Presentation) |
|
||
if (canceled) { | ||
container.destroy(); | ||
return; | ||
} | ||
|
||
if (isErrorEmbeddable(container)) { |
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.
Shouldn't setLoading(false);
get called if container is an error embeddable? The container finished loading, even if it loaded in an error state
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.
Good call, I didn't catch that because the error was rendered if it was present no matter if the loading state was true or not. I've straightened that out!
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
code review only
@@ -133,7 +144,9 @@ export const DashboardRenderer = forwardRef<AwaitingDashboardAPI, DashboardRende | |||
|
|||
return ( | |||
<div className={viewportClasses}> | |||
{loading ? loadingSpinner : <div ref={dashboardRoot} />} | |||
{loading && loadingSpinner} |
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.
nit, there should never be a case where loadingSpinner and fatalError.render() are displayed but there could be if both loading and fatalError are set. Would it be clearer to move this logic to a function and use early returns so only a single item is rendered. For example
function renderContent() {
if (loading) {
return loadingSpinner;
}
if (fatalError) {
return fatalError.render();
}
return (<div ref={dashboardRoot} />);
}
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.
That's true. Even if it wouldn't necessarily happen, it's still much cleaner and more understandable to do it this way.
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
Waiting for #157437 to be backported to 8.8 before this one can be. |
@ThomThomson looks like #157437 got backported to 8.x right? |
Makes dashboard load errors recoverable. Fixes a regression where Alias redirects resulted in infinite loading. (cherry picked from commit e7528a2)
#159937) # Backport This will backport the following commits from `main` to `8.8`: - [[Dashboard] Fix alias redirect & update error handling (#159742)](#159742) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Devon Thomson","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-15T15:57:43Z","message":"[Dashboard] Fix alias redirect & update error handling (#159742)\n\nMakes dashboard load errors recoverable. Fixes a regression where Alias redirects resulted in infinite loading.","sha":"e7528a2372c846020d565f229da9052ba316284c","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Dashboard","release_note:fix","Team:Presentation","loe:days","impact:critical","backport:prev-minor","v8.9.0"],"number":159742,"url":"https://github.com/elastic/kibana/pull/159742","mergeCommit":{"message":"[Dashboard] Fix alias redirect & update error handling (#159742)\n\nMakes dashboard load errors recoverable. Fixes a regression where Alias redirects resulted in infinite loading.","sha":"e7528a2372c846020d565f229da9052ba316284c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159742","number":159742,"mergeCommit":{"message":"[Dashboard] Fix alias redirect & update error handling (#159742)\n\nMakes dashboard load errors recoverable. Fixes a regression where Alias redirects resulted in infinite loading.","sha":"e7528a2372c846020d565f229da9052ba316284c"}}]}] BACKPORT-->
Summary
This PR fixes a regression introduced in #150121 & #157437.
Basically what would happen is the following:
This PR fixes that with proper error handling on the dashboard container factory side, and the ability for the dashboard renderer to retry loading the dashboard container if the last load was unsuccessful.
Before
Before.mp4
After
After.mp4
Bonus
Additionally, this PR straightens out the error handling on Dashboard creation. If an error embeddable is returned from the dashboard container factory, the dashboard renderer will render it until the id changes. I got this screenshot by throwing an error in
create_dashboard.ts
.Checklist
Delete any items that are not applicable to this PR.