-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dashboard] Prevent unnecessary loss of dashboard unsaved state (#167707
) Closes #167661 ## Summary After a whole bunch of investigation, I ultimately realized that the attached test was flaky because the dashboard session storage was being cleared in the `DashboardUnsavedListing` component. When loading the unsaved dashboards, we used to remove the unsaved state for dashboards that returned **any** error from the CM service - this was designed so that, if a dashboard was deleted, we would remove it from the unsaved dashboard listing callout. However, as an unintended consequence, **other** errors, which should **not** cause the unsaved state to be lost, also caused it to be cleared. Since I could only replicate **some** of the possible CM errors locally, it was impossible to narrow down exactly what error was being thrown in the attached flaky test since the FTR does not provide console logs. Therefore, rather than **preventing** that specific error from clearing the session storage, I instead made it so that **only** `404` errors (i.e. `"Saved object not found"` errors) cause the session storage to be cleared - this will guarantee that we only remove the unsaved state from the session storage if we know **for sure** that the dashboard has been deleted. Any other errors that are thrown by the CM will **not** cause the unsaved state to be unnecessarily lost. Also, in my attempt to solve the above flaky test, I discovered and fixed the following: 1. Previously, when an error was thrown and caught in the `DashboardUnsavedListing` component, the `refreshUnsavedDashboards` would cause a `useEffect` infinite loop because the reference for the `unsavedDashboardIds` array would always be different even if the contents of the array were identical. This PR fixes that by ensuring the array reference **only** changes if the contents change. 2. Our previous way of catching errors in the `findDashboardById` method was not reliable, and did not catch errors that were thrown in, for example, the CM client `get` method. I refactored this so that all errors should now be caught. ### [Flaky Test Runner](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3554) ![image](https://github.com/elastic/kibana/assets/8698078/1bcd9d6a-0c37-43ee-b5d6-f418cf878b41) ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
7 changed files
with
55 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters