Skip to content

fix(files): keep the shared markdown parser editor unmounted - #8308

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/markdown-parser-headless
Sep 25, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/markdown-parser-headless

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • The shared markdown parse/serialize editor in markdown-parse.ts was mounted, so every serialize rendered the doc into a hidden DOM view. ProseMirror's DOMObserver schedules a 20ms flush timer it never tracks, so nothing can cancel it; in jsdom suites it fired after teardown and failed CI with ReferenceError: document is not defined in whichever test file happened to finish first
  • Build that editor unmounted (element: null), with no view, observer, or timers. TipTap only installs extension plugins on mount, so they're installed via state.reconfigure the same way, keeping normalization (e.g. the trailing paragraph) identical to the live editor
  • serializeDocToMarkdown sets content with emitUpdate: false: nothing listens to the scratchpad, and the update made TipTap's core Delete extension defer a timer on every serialize
  • markdown-paste.test.ts leaked a mounted editor: its single editor slot was overwritten when one test mounted twice, so the first was never destroyed and its observer timer could fire after teardown. mount() now registers every editor and afterEach destroys them all (an audit of every file-viewer test found no other leak)
  • Drop a dead cleanups hook from block-image-paragraph.test.ts that nothing pushes into

Type of Change

  • Bug fix

Testing

  • Reproduced deterministically in a scratch jsdom test (serialize, drop document, wait): old code throws the exact CI error, new code throws nothing
  • Serialization parity: all 705 .md/.mdx files in the repo serialize byte-identically through a mounted editor vs the new unmounted one
  • Regression test in markdown-parse.test.ts: fresh module under fake timers, serialize, assert no pending timers. Red in whole-file runs with the editor mounted again, with the update emitted, and on the pre-PR file; green with the fix
  • rich-markdown-editor + collab-doc suites pass (771 tests); type-check, lint, check:audits (49 audits), docs-manifest:check pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 25, 2026 8:51pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Fixes timer leaks in the shared markdown parser.

The PR appears safe to merge; no outstanding finding or new actionable issue was identified.

Summary

The PR keeps the shared Markdown parser editor unmounted to avoid deferred DOM-observer work, suppresses unnecessary scratchpad updates, and tightens test cleanup and timer coverage.

Reviews (3) · Last reviewed commit: "fix(files): destroy every editor a markd..."

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 8bebab9 into staging Sep 25, 2026
32 of 33 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/markdown-parser-headless branch September 25, 2026 22:07

This branch was previously deployed

1 inactive deployment
Preview — 4e31bbc4 Deployed Sep 25, 2026 by vercel[bot]
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