Skip to content

fix(ourlogs): stabilize ECharts chart position to prevent getAttribute crash#115753

Open
JoshuaKGoldberg wants to merge 6 commits into
masterfrom
fix/stabilize-echarts-chart-render-tree
Open

fix(ourlogs): stabilize ECharts chart position to prevent getAttribute crash#115753
JoshuaKGoldberg wants to merge 6 commits into
masterfrom
fix/stabilize-echarts-chart-render-tree

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg commented May 18, 2026

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

ChartVisualization currently renders TimeSeriesWidgetVisualization in two structurally different tree positions based on its state:

  • Loading with previous data: StyledTransparentLoadingMaskTimeSeriesWidgetVisualization
  • Loaded: TimeSeriesWidgetVisualization (direct return, no wrapper)

I believe that was causing charts to unmount & mount on some loading→loaded transitions. echarts-for-react can have an update queued (via requestAnimationFrame) at the moment of unmount. When that queued callback fires, it calls getEchartsInstance() on this.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 wraps TimeSeriesWidgetVisualization in StyledTransparentLoadingMask, changing only its visible and (new) opaque prop. The chart stays mounted across loading transitions and the DOM ref stays valid.

  • A nice benefit of this is we don't have to do work unmounting and then mounting the chart unnecessarily!
  • To support this, in timeSeriesWidgetVisualization.tsx I added 'series' to replaceMerge (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)

…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>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 18, 2026
@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(logs): Stabilize echarts chart position to prevent getAttribute crash fix(logs): stabilize ECharts chart position to prevent getAttribute crash May 18, 2026
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 18, 2026

LOGS-756

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.56%

@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(logs): stabilize ECharts chart position to prevent getAttribute crash fix(ourlogs): stabilize ECharts chart position to prevent getAttribute crash May 19, 2026
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review May 19, 2026 14:12
@JoshuaKGoldberg JoshuaKGoldberg requested review from a team as code owners May 19, 2026 14:12
Comment thread static/app/views/explore/components/chart/chartVisualization.tsx Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread static/app/views/explore/components/chart/chartVisualization.tsx
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as draft May 19, 2026 14:25
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review May 19, 2026 18:02
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner May 19, 2026 18:02
Comment thread static/app/views/explore/components/chart/chartVisualization.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant