Skip to content

fix(react): use circularDeepEqual in useEditorState to prevent stack overflow#7487

Open
naaa760 wants to merge 1 commit intoueberdosis:mainfrom
naaa760:fix/pss-crsh-swit-eql
Open

fix(react): use circularDeepEqual in useEditorState to prevent stack overflow#7487
naaa760 wants to merge 1 commit intoueberdosis:mainfrom
naaa760:fix/pss-crsh-swit-eql

Conversation

@naaa760
Copy link

@naaa760 naaa760 commented Feb 2, 2026

Changes Overview

  • Default equality in useEditorState changed from deepEqual to circularDeepEqual.

Implementation Approach

  • Import and default equalityFn now use circularDeepEqual.
  • JSDoc updated for the default equality function.
  • No other logic or APIs changed.

Testing Done

  • Build passes.
  • Behavior unchanged for non-circular selector results.

Verification Steps

  • Use an app that uses useEditorState with editor state.
  • Confirm no "Maximum call stack size exceeded" and re-renders still work.

Additional Notes

  • Fixes regression from switching fast-deep-equal to fast-equals (circular refs).

Checklist

[ ] Changeset if needed.
[ ] No library breakage.

fix: #7482

@netlify
Copy link

netlify bot commented Feb 2, 2026

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 675abfe
🔍 Latest deploy log https://app.netlify.com/projects/tiptap-embed/deploys/6980ad9efdb20700080f71c3
😎 Deploy Preview https://deploy-preview-7487--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link

changeset-bot bot commented Feb 2, 2026

🦋 Changeset detected

Latest commit: 675abfe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 72 packages
Name Type
@tiptap/extension-link Patch
@tiptap/starter-kit Patch
@tiptap/core Patch
@tiptap/extension-audio Patch
@tiptap/extension-blockquote Patch
@tiptap/extension-bold Patch
@tiptap/extension-bubble-menu Patch
@tiptap/extension-bullet-list Patch
@tiptap/extension-code-block-lowlight Patch
@tiptap/extension-code-block Patch
@tiptap/extension-code Patch
@tiptap/extension-collaboration-caret Patch
@tiptap/extension-collaboration Patch
@tiptap/extension-color Patch
@tiptap/extension-details Patch
@tiptap/extension-document Patch
@tiptap/extension-drag-handle-react Patch
@tiptap/extension-drag-handle-vue-2 Patch
@tiptap/extension-drag-handle-vue-3 Patch
@tiptap/extension-drag-handle Patch
@tiptap/extension-emoji Patch
@tiptap/extension-file-handler Patch
@tiptap/extension-floating-menu Patch
@tiptap/extension-font-family Patch
@tiptap/extension-hard-break Patch
@tiptap/extension-heading Patch
@tiptap/extension-highlight Patch
@tiptap/extension-horizontal-rule Patch
@tiptap/extension-image Patch
@tiptap/extension-invisible-characters Patch
@tiptap/extension-italic Patch
@tiptap/extension-list Patch
@tiptap/extension-mathematics Patch
@tiptap/extension-mention Patch
@tiptap/extension-node-range Patch
@tiptap/extension-ordered-list Patch
@tiptap/extension-paragraph Patch
@tiptap/extension-strike Patch
@tiptap/extension-subscript Patch
@tiptap/extension-superscript Patch
@tiptap/extension-table-of-contents Patch
@tiptap/extension-table Patch
@tiptap/extension-text-align Patch
@tiptap/extension-text-style Patch
@tiptap/extension-text Patch
@tiptap/extension-twitch Patch
@tiptap/extension-typography Patch
@tiptap/extension-underline Patch
@tiptap/extension-unique-id Patch
@tiptap/extension-youtube Patch
@tiptap/extensions Patch
@tiptap/html Patch
@tiptap/markdown Patch
@tiptap/pm Patch
@tiptap/react Patch
@tiptap/static-renderer Patch
@tiptap/suggestion Patch
@tiptap/vue-2 Patch
@tiptap/vue-3 Patch
@tiptap/extension-character-count Patch
@tiptap/extension-dropcursor Patch
@tiptap/extension-focus Patch
@tiptap/extension-gapcursor Patch
@tiptap/extension-history Patch
@tiptap/extension-list-item Patch
@tiptap/extension-list-keymap Patch
@tiptap/extension-placeholder Patch
@tiptap/extension-table-cell Patch
@tiptap/extension-table-header Patch
@tiptap/extension-table-row Patch
@tiptap/extension-task-item Patch
@tiptap/extension-task-list Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

@krehwell krehwell left a comment

Choose a reason for hiding this comment

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

we have add title support for link related too in this PR

but the useEditorState one is good on my end

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses a critical stack overflow bug in @tiptap/react's useEditorState hook (issue #7482) by switching from deepEqual to circularDeepEqual to handle circular references in editor state. The PR also includes additional changes to the Link extension, adding support for the title attribute in markdown rendering.

Changes:

  • Fixed stack overflow in useEditorState by using circularDeepEqual instead of deepEqual from fast-equals
  • Added title attribute support to Link extension for markdown serialization/deserialization
  • Added test coverage for links with and without title attributes in markdown conversion tests

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/react/src/useEditorState.ts Changed default equality function from deepEqual to circularDeepEqual to prevent stack overflow with circular references
packages/extension-link/src/link.ts Added title attribute to Link extension schema and updated markdown rendering to support title serialization
packages/markdown/tests/conversion-files/link-with-title.ts New test file for link markdown conversion with title attribute
packages/markdown/tests/conversion-files/link-without-title.ts New test file for link markdown conversion without title attribute
packages/markdown/tests/conversion-files/index.ts Exported new link test modules
.changeset/link-title-markdown.md Changeset for Link markdown rendering changes
.changeset/link-title-attribute.md Changeset for Link title attribute addition

@@ -1,5 +1,5 @@
import type { Editor } from '@tiptap/core'
import { deepEqual } from 'fast-equals'
import { circularDeepEqual } from 'fast-equals'
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

Missing changeset for the React fix. The PR description indicates this is a fix for issue #7482 (stack overflow in useEditorState), but there's no changeset file for the @tiptap/react package. According to the project guidelines, user-facing changes require a changeset.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Member

Choose a reason for hiding this comment

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

Can you extract your link changes into an extra PR please?

target?: string | null
rel?: string | null
class?: string | null
title?: string | null
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

Discrepancy between PR description and changes. The PR title and description focus on fixing the stack overflow issue in useEditorState, but the PR also includes unrelated changes to the Link extension (adding title attribute support) and markdown test files. These Link extension changes should either be mentioned in the PR description or moved to a separate PR for better change tracking and review clarity.

Copilot uses AI. Check for mistakes.
@bdbch bdbch changed the base branch from develop to main March 14, 2026 15:04
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.

Possible crash after switching from fast-deep-equal to fast-equals

4 participants