Skip to content

fix(web-console): prevent infinite state updates in metrics#469

Merged
emrberk merged 4 commits intomainfrom
fix/metrics-state
Aug 29, 2025
Merged

fix(web-console): prevent infinite state updates in metrics#469
emrberk merged 4 commits intomainfrom
fix/metrics-state

Conversation

@emrberk
Copy link
Collaborator

@emrberk emrberk commented Aug 29, 2025

Reworked the state management of this component, ensuring updates all go through the updateBuffer call, no redundant local state, no unnecessary rerenders, no mutations on context values.

  • Metrics component was getting the buffers object from Dexie, setting a local state, and was not properly syncing local state with the storage.
  • In some cases, we were running effect to set the local state because context value changed -> running effect to set the context value -> .... This was causing infinite loops. -> removed redundant local state and effects
  • We had a focus listener but it did not have any effect -> removed
  • We had a visibility check but ref was being set only when telemetry is disabled -> reversed, it is set when telemetry is enabled

@emrberk emrberk requested a review from Copilot August 29, 2025 12:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes infinite state update loops in the Metrics component by reworking state management to eliminate redundant local state and ensure all updates go through the updateBuffer call.

  • Removed local state variables and replaced them with direct access to buffer state
  • Eliminated redundant effects that were causing infinite loops between local and context state
  • Fixed visibility check implementation to properly set ref when telemetry is enabled

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/web-console/src/scenes/Editor/index.tsx Added key prop to Metrics component to force remount on buffer changes
packages/web-console/src/scenes/Editor/Metrics/index.tsx Removed local state management, fixed infinite update loops, and streamlined state synchronization
packages/browser-tests/questdb Updated subproject commit reference

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

emrberk and others added 2 commits August 29, 2025 15:56
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@emrberk emrberk changed the title fix(web-console): prprevent infinite state updates in metrics fix(web-console): prevent infinite state updates in metrics Aug 29, 2025
Copy link

@javier javier left a comment

Choose a reason for hiding this comment

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

The error is fixed now

@emrberk emrberk requested a review from glasstiger August 29, 2025 14:03
@emrberk emrberk merged commit 6a5d8b9 into main Aug 29, 2025
4 checks passed
@emrberk emrberk deleted the fix/metrics-state branch August 29, 2025 14:42
Vaibhav91one pushed a commit to Vaibhav91one/ui that referenced this pull request Oct 28, 2025
)

* fix(web-console): prprevent infinite state updates in metrics

* submodule

* Update packages/web-console/src/scenes/Editor/Metrics/index.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* copilot mess

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants