-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'matchesNode' of null (TipTap for React) #1451
Comments
Did you try upgrading all your dependencies? The core is at beta.81 already. |
Same issue on my end Updated all my dependencies to the latests to try out, the issue still shows up. For me it starts at |
Thanks for the suggestion. Issue still persists using: |
@chasinhues is there any workaround? |
Not that I'm aware of |
@chasinhues I hope the following would help spotting the root cause. This issue happens to me in editor.setContent() after hot-reload and when creating an editor dynamically, it also happens when dynamically adding multiple editors without delay. If I wait for a second after creating an editor before re-creating another one, it doesn't occur. It seems that successive dynamic creation error is due to setTimeout(() => editor.createNodeViews(), 0) in EditorContent. I also suspect that this error causes the setContent() one too. I added try-catch around setContent() with 3 retries separated by a delay of 100ms. However, the createNodeViews() does not seem to be catchable from the component. Is there any chance of a hotfix to prevent this uncaught error from propagating since the software will be shipped soon :( ? |
We're hitting this and have updated our dependencies to all the latest tiptap versions as of 2 days ago (see below): This may be happening when we destroy the editor and then recreate it again. Is there any guidance on timing for destroying the editor before instantiating a new one?
|
This patch should fix that error. |
@philippkuehn Thank you for the patch! |
Yeah I'm still noticing this as obezzad mentioned, even after upgrading to the patch with the fix.
|
We were able to hack around this by adding checks for Could we update editor.commands to do this check automatically, and never try to run a command when the editor itself is destroyed? That might catch a lot of issues. However, even after adding this, hot reload still triggered an error in the Yjs sync plugin, see screenshot below. It looks like that can also be suppressed by adding |
@thatsjonsense Thank you for the workaround. I believe all the matchesNode errors are due editor.isDestroyed not checked. This may not be an issue in Vue, but React seems to work differently. @philippkuehn Can you re-open this issue, or should we create another issue and refer to this one? |
The CollaborationCursorPlugin throws the same error in some circumstances. We use the react TipTap package with the collab feature. Our editor can be opened and closed within our application - the open/close state is synced with all currently connected clients via websocket. The error occurs when a user is still inside the editor, while the editor is closed by someone else. The root cause is the same as described here: #438 (comment) |
I have the same issue with
However it would probably make more sense to check it in |
can solve this problem. |
Hey @philippkuehn, I think I've found a more general solution to this that prevents the error. A little hacky but let me know what you think
|
@thatsjonsense Really a bit hacky :) Do you still see this error? Haven't seen it for ages. |
Yep, all the time :( I believe it’s coming from inside the collaboration
plug-ins during hot reload. They try to update some stage after the editor
is destroyed, before it is recreated
On Fri, Oct 29, 2021 at 1:02 AM Philipp Kühn ***@***.***> wrote:
@thatsjonsense <https://github.com/thatsjonsense> Really a bit hacky :)
Do you still see this error? Haven't seen it for ages.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1451 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQ5BWPHVOPIFENHMWJ7UXLUJJPKBANCNFSM46P7VDZA>
.
--
Jon Noronha
Cofounder, Gamma
|
I also see this regularly. I am using Snowpack with HMR and Fast Refresh. (https://www.snowpack.dev/concepts/hot-module-replacement) I have a React app with a component that wraps TipTap named Adding the lines from @thatsjonsense 's comment above to Versions:
|
Experienced this as well. Not hot-reloading. Also using multiple editors on the same page. |
I modified the code by @thatsjonsense to reuse the old updateState:
This bug was apparently fixed in [email protected], but this same version introduced another issue: So I had to downgrade to [email protected] and this problem still exists there. |
For me the error also came with a modal function where the editor was not visible. I solved the problem by checking if the plugins are loaded. export const resetContent = () => {
if (editor.view.pluginViews.length) {
editor.commands.clearContent();
}
}; |
I'm still getting this issue in development, for me it occurs when my styled component wrapper gets resaved - it triggers the error. I've gotten around it by extracting editor explicitly into its own component and passing back to the parent component that has the styled component wrapper. using:
|
This error also seems to be triggered by StrictMode, because the component is immediatly unmounted and remounted. |
From time to time we are experiencing the same issue, this workaround #1451 (comment) works well, but is there any other recommendations since then? Thanks |
It's not completely tiptap-relateded, but I had this issue because I implemented an asynchronous ProseMirror plugin. If I closed the editor before the asynchronous call resolved, the program tried to update a view that didn't exist anymore. My code was something like that: asynchronousApiCall().then(data => {
// this could happen after my editor is closed
view.dispatch(view.state.tr.setMeta("call resolved", data)
}) And I added the following check: asynchronousApiCall().then(data => {
// check if the editor is still alive
if (!(view as any)?.docView) return
view.dispatch(view.state.tr.setMeta("call resolved", data)
}) |
I encountered this issue when adding dependencies to If I don't add the dependencies to the array I don't get this error when I have multiple editors on the same page. As I add deps to get it to react to being moved/destroyed I get this error. I I used #1451 (comment) solution and removing the dependency array. This seems like a bug to me, I'm just getting a less granular solution to what I assume useEditor does under the hood. |
It has been almost two years and there is no solution in sight. |
I've just followed the official documentation for installing TipTap into NextJS and got this bug. Latest TipTip and NextJS. I just copy pasted the example code without adding anything. I tried all fixes and nothing seems to work. (I'm not sure if I was doing correctly.) Whenever I change something in the component I see this error in the browser. Is there any other was I could make this work? |
@vaetas Assuming your issue is caused by the same root cause as the issue I submitted, it was fixed in v2.0.0-beta.220! |
This was ultimately the only thing that solved the problem for us. Echoing the question by @thatsjonsense: is this something that is possible for TipTap to check internally when commands are executing against an instance of the editor? |
Did you open a PR for it? I don't think they are planning to fix this. |
The remix app was also giving an error on every hot reload due to StrictMode, removing StrictMode worked fine. |
I am using Remix v2 and have the same problem on every hot reload. I use useEditor(). I did not see a solution/workaround for people using that hook, maybe someone solved this though? |
1. localStorage에 postKind가 지정되어있지 않을 경우 postKind를 글 모드로 지정, 이 때 대소문자 오타가 있어 수정함 (article -> ARTICLE) 2. 글, 그림모드 전환 시 오류 발생 <img width="588" alt="image" src="https://github.com/penxle/penxle/assets/76952602/27089364-6f07-4e0f-8d10-79544ed3077c"> 아래 내용 참고해 버블메뉴, 플로팅 메뉴 코드 수정함 ueberdosis/tiptap#1451
where do you put this line? |
https://codesandbox.io/p/sandbox/tiptap-newline-error-kpgm8?file=%2Fsrc%2FApp.tsx%3A6%2C10-6%2C20 |
Hello, can you kindly explain to me exactly where I need to apply the codes? I am lost and I see this error. |
got the same error today when trying to update from 2.2.4 to 2.4.0 . workaround didn’t solve it, so switched back to 2.2.5, which is the latest version which works for me. using multiple editors on the same page as others also mentioned. |
Description
Same issue as in #438. TypeError that crashes my app.
Steps to reproduce the bug
Happens on occasion when navigating to a page with a TipTap editor on it.
CodeSandbox
In the CSB below, run the tests, and observe the console spits out a bunch of these type errors for the browser. I don't know why it does this...
https://codesandbox.io/s/tiptap-prose-matchesnode-error-yhvdc
Expected behavior
No error.
Environment?
@tiptap/core@^2.0.0-beta.65
Additional context
I tried to keep the CSB example above as close to my current code as possible, minus other third-party libraries that would unnecessarily bloat the example.
I am able to replicate the error consistently in my tests:
The text was updated successfully, but these errors were encountered: