fix(ourlogs): stabilize ECharts chart position to prevent getAttribute crash#115753
Open
JoshuaKGoldberg wants to merge 6 commits into
Open
fix(ourlogs): stabilize ECharts chart position to prevent getAttribute crash#115753JoshuaKGoldberg wants to merge 6 commits into
JoshuaKGoldberg wants to merge 6 commits into
Conversation
…rash ChartVisualization previously rendered TimeSeriesWidgetVisualization in two structurally different tree positions — directly as the root when data was loaded, and wrapped in StyledTransparentLoadingMask while loading with previous data. React unmounts the whole subtree when the root type changes, so the chart was recreated on every loading→loaded transition. echarts-for-react can have an update queued via requestAnimationFrame at the moment of unmount, causing it to call getEchartsInstance() on a now-detached DOM node (this.ele is null), producing the TypeError. Fix by always rendering TimeSeriesWidgetVisualization under StyledTransparentLoadingMask and toggling only its visible prop. The chart stays mounted across loading transitions so the DOM ref stays valid. Also add 'series' to replaceMerge in TimeSeriesWidgetVisualization so that stale series from a previous render are fully replaced rather than merged when notMerge=false, preventing inconsistent internal echarts state when the series count changes. Fixes LOGS-756 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.56% |
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c0ff572. Configure here.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

I still haven't been able to reproduce this locally. It's a bit intricate, so posting a bit more detailed of a PR breakdown than usual...
Root cause
ChartVisualizationcurrently rendersTimeSeriesWidgetVisualizationin two structurally different tree positions based on its state:StyledTransparentLoadingMask→TimeSeriesWidgetVisualizationTimeSeriesWidgetVisualization(direct return, no wrapper)I believe that was causing charts to unmount & mount on some loading→loaded transitions.
echarts-for-reactcan have an update queued (viarequestAnimationFrame) at the moment of unmount. When that queued callback fires, it callsgetEchartsInstance()onthis.ele-the now-detached DOM node- which is null. I'm pretty sure that's: hustcc/echarts-for-react#620 💥Fix
chartVisualization.tsx: merge the two "has data" branches into a single return path that always wrapsTimeSeriesWidgetVisualizationinStyledTransparentLoadingMask, changing only itsvisibleand (new)opaqueprop. The chart stays mounted across loading transitions and the DOM ref stays valid.timeSeriesWidgetVisualization.tsxI added'series'toreplaceMerge(alongside existing'xAxis'and'yAxis'). I think this'll help prevent odd merges from chart state transitions that are the same and were previously not merging due to unmounting & mounting anew.Closes LOGS-756 (this time for real, I hope)