[ChromeNext] Add a switch to toggle chrome-next in devbar#260952
[ChromeNext] Add a switch to toggle chrome-next in devbar#260952Dosant merged 1 commit intoelastic:feature/chrome-nextfrom
chrome-next in devbar#260952Conversation
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
kowalczyk-krzysztof
left a comment
There was a problem hiding this comment.
Ideally it would be useful if we could have solution switcher somehow working without doing the hard work 😆 but this is good too!
I've been running two Kibanas recently, one on the feature branch, one on main just for solution switcher so see if things don't randomly break in different solutions.
| export const toggleNextChrome = (featureFlags: FeatureFlagsStart): void => { | ||
| const next = !isNextChrome(featureFlags); | ||
| sessionStorage.setItem(NEXT_CHROME_SESSION_STORAGE_KEY, String(next)); | ||
| window.location.reload(); | ||
| }; |
There was a problem hiding this comment.
🟢 Low feature-flags/index.ts:29
toggleNextChrome calls sessionStorage.setItem() without a try-catch, so if sessionStorage is unavailable (e.g., private browsing mode, security restrictions), clicking the toggle throws an uncaught exception. Consider wrapping the setItem call in a try-catch to match the graceful handling in isNextChrome, or at least catch and ignore the error to avoid crashing.
export const toggleNextChrome = (featureFlags: FeatureFlagsStart): void => {
const next = !isNextChrome(featureFlags);
- sessionStorage.setItem(NEXT_CHROME_SESSION_STORAGE_KEY, String(next));
- window.location.reload();
+ try {
+ sessionStorage.setItem(NEXT_CHROME_SESSION_STORAGE_KEY, String(next));
+ window.location.reload();
+ } catch {
+ // sessionStorage may be unavailable
+ }
};🤖 Copy this AI Prompt to have your agent fix this:
In file src/core/packages/chrome/feature-flags/index.ts around lines 29-33:
`toggleNextChrome` calls `sessionStorage.setItem()` without a try-catch, so if `sessionStorage` is unavailable (e.g., private browsing mode, security restrictions), clicking the toggle throws an uncaught exception. Consider wrapping the `setItem` call in a try-catch to match the graceful handling in `isNextChrome`, or at least catch and ignore the error to avoid crashing.
Evidence trail:
src/core/packages/chrome/feature-flags/index.ts lines 17-31 at REVIEWED_COMMIT:
- Lines 17-25: `isNextChrome` has try-catch around `sessionStorage.getItem()` with comment '// sessionStorage may be unavailable'
- Lines 27-31: `toggleNextChrome` calls `sessionStorage.setItem()` at line 29 with no try-catch protection
Summary
Note: it is possible to make it work without a page reload, but I thought it was not worth the complexity.