Skip to content

fix(app): bump happy-dom to fix GC-dependent MutationObserver flake - #46675

Merged
rekram1-node merged 2 commits into
devfrom
fix-happydom-flake
Sep 1, 2026
Merged

rekram1-node merged 2 commits into
devfrom
fix-happydom-flake

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Summary

The unit (linux) job on dev has been flaking on observe-element-offset.test.ts (e.g. https://github.com/anomalyco/opencode/actions/runs/33552710331/job/100005843576):

(fail) reports a divergent native offset once and ignores equal offsets and unrelated mutations
expect(calls).toEqual([[0, false]])  // received []

Root cause is a happy-dom bug, not the test or the timeline code. In happy-dom@20.9.0 (what the lockfile resolved), MutationObserverListener stores its per-node callback only as new WeakRef((record) => this.report(record)) with nothing holding the closure strongly. If Bun's GC runs between observe() and the DOM mutation, the closure is collected and the observer silently never fires. Whether that happens depends on heap pressure from the ~700 other tests in the same process, hence the flake.

This is deterministically reproducible with Bun.gc(true) between observe() and a mutation, and was fixed upstream in capricorn86/happy-dom#2272 (first shipped in 20.11.2), which keeps a strong #listenerCallback reference.

Change

  • Bump @happy-dom/global-registrator 20.0.11 -> 20.12.0 in packages/app, which pulls in happy-dom@20.12.0.

Verification

  • GC repro (forced Bun.gc(true) before mutation) fails on the old version and passes on 20.12.0
  • packages/app unit suite: 723/724 pass; the one failure (desktop-native.test.ts pa-PK likely-subtags) is pre-existing on dev locally and passes in CI (macOS vs Linux ICU data), unrelated to this change
  • bun typecheck in packages/app passes

@rekram1-node
rekram1-node merged commit 8100c68 into dev Sep 1, 2026
9 checks passed
@rekram1-node
rekram1-node deleted the fix-happydom-flake branch September 1, 2026 21:00
filipeforattini added a commit to reddb-io/redcode that referenced this pull request Sep 5, 2026
filipeforattini added a commit to reddb-io/redcode that referenced this pull request Sep 5, 2026
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.

1 participant