Skip to content

[Dashboard] Fix search session restoration bug#239822

Merged
Heenawter merged 7 commits intoelastic:mainfrom
Heenawter:fix-dashboard-search-sessions_2025-10-20
Oct 22, 2025
Merged

[Dashboard] Fix search session restoration bug#239822
Heenawter merged 7 commits intoelastic:mainfrom
Heenawter:fix-dashboard-search-sessions_2025-10-20

Conversation

@Heenawter
Copy link
Contributor

@Heenawter Heenawter commented Oct 20, 2025

Part of #239610

Summary

Previously, we were never hitting the search session cache for dashboards with controls because we were removing the search session ID from the URL and generating a new session once controls published their filters, which lead us to fetch the new ID rather than the saved one:

SearchSessionMismatch

Note

Notice in the above network request that isRestore is false, which shows that we are not restoring an existing search session (dd41248d-3dd7-41e6-99f0-e30c6b4a87f1); instead; we are fetching from the newly generated one (1f48aacc-90c5-4081-8157-b9b6d77b33b4).

This was because we weren't awaiting the dashboard controls to publish their filters, which caused newSession$ to emit prematurely and triggered removing the search session ID from the URL before the search session actually had a chance to be restored. Now, we avoid generating a new search session ID until after controls have published their filters.

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.
@Heenawter Heenawter self-assigned this Oct 20, 2025
@Heenawter Heenawter added release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// loe:small Small Level of Effort impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. backport:version Backport to applied version labels v9.2.0 v9.1.6 labels Oct 20, 2025
@Heenawter Heenawter force-pushed the fix-dashboard-search-sessions_2025-10-20 branch from 20a5fa1 to 8a87017 Compare October 21, 2025 22:41
@Heenawter Heenawter marked this pull request as ready for review October 22, 2025 20:25
@Heenawter Heenawter requested a review from a team as a code owner October 22, 2025 20:25
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 664.0KB 664.1KB +79.0B

History

cc @Heenawter

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM! Glad to see a usage of isFetchPaused$. Thank you for fixing this.

@Heenawter Heenawter merged commit 5b0b2dc into elastic:main Oct 22, 2025
13 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.1, 9.2

https://github.com/elastic/kibana/actions/runs/18729374384

@Heenawter Heenawter deleted the fix-dashboard-search-sessions_2025-10-20 branch October 22, 2025 20:49
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Oct 22, 2025
Part of elastic#239610

## Summary

Previously, we were **never** hitting the search session cache for
dashboards with controls because we were removing the search session ID
from the URL and generating a new session once controls published their
filters, which lead us to fetch the **new** ID rather than the saved
one:

<img width="1814" height="1061" alt="SearchSessionMismatch"
src="https://github.com/user-attachments/assets/bd7f0f62-99c9-4537-ac56-863162f5e0fb"
/>

> [!NOTE]
> Notice in the above network request that `isRestore` is false, which
shows that we are not restoring an existing search session
(`dd41248d-3dd7-41e6-99f0-e30c6b4a87f1`); instead; we are fetching from
the newly generated one (`1f48aacc-90c5-4081-8157-b9b6d77b33b4`).

This was because we weren't awaiting the dashboard controls to publish
their filters, which caused `newSession$` to emit prematurely and
triggered removing the search session ID from the URL before the search
session actually had a chance to be restored. Now, we avoid generating a
new search session ID until **after** controls have published their
filters.

### 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
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 5b0b2dc)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
9.1 Backport failed because of merge conflicts
9.2

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 239822

Questions ?

Please refer to the Backport tool documentation

@Heenawter Heenawter added backport:skip This PR does not require backporting v9.3.0 and removed backport:version Backport to applied version labels v9.2.0 labels Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:small Small Level of Effort release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v9.3.0

4 participants