Skip to content

[P1] [bug] TruncatedCell ResizeObserver leak on frequent updates #417

Closed

Description

@EVWorth

[P1] [bug] TruncatedCell's ResizeObserver recreated on every value change — leak in tables with frequent updates

Context

TruncatedCell.tsx:23-39 useEffect deps are [formatted, columnName, dataType]. For cells with frequently-changing values (e.g., SELECT NOW() polling, edit-mode keystrokes), the effect tears down and re-creates the ResizeObserver on every render.

Problem

Per docs/audits/results.md F22.

With 100 visible cells × 60 renders/sec, that's 6000 ResizeObserver instances/sec. GC pressure mounts; profile climbs to 100% CPU on idle scroll.

Files

  • src/components/grid/TruncatedCell.tsx:23-39

Repro (if applicable)

Static analysis only.

Expected

A 100-row SELECT NOW() polling every second stays at ~60% CPU on idle scroll, not climbing to 100%. ResizeObserver count stays bounded.

Proposed fix

Scope S. useMemo(() => formatted, [formatted]) on the formatted string; or pass value as the dep instead of formatted so the effect doesn't re-run when output is identical. Skip observer if column type is not long-text/blob/json.

Acceptance

ResizeObserver instances don't grow with render rate; CPU stays bounded.

Needs human verify

Yes

Labels: audit, area/results, severity/p1, kind/bug

Activity

  1. added
    audit
    severity/p1
    kind/bug
    area/results
    on Jul 31, 2026
  2. EVWorth commented on Sep 11, 2026

    @EVWorth
    OwnerAuthor

    Already fixed, in fdd8919 ("stop hijacking the wheel, and stop rebuilding observers", #542).

    TruncatedCell.tsx:62-76 now constructs the ResizeObserver in an effect with an empty dependency list — one per mounted cell, for as long as it is mounted. columnName and dataType went too; neither has any bearing on whether text overflows its box.

    The measurement the old effect was really doing still re-runs per value, as a separate layout read, because text can change without the box resizing.

    Covered by describe("observer churn") in TruncatedCell.test.tsx: 25 value changes leave exactly one observer, and changing the column metadata leaves it alone too.

    One correction to the issue: nothing leaked. The cleanup did disconnect each observer, so the cost was construction churn and the CPU it burnt, not unbounded growth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/resultsauditkind/bugseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions