You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My users and I noticed this issue in my program Codex, that when you create a code block with a language it works fine, but when you create a code block with no language to be auto-highlighted, it freezes the program for 10+ seconds and spits out an Uncaught RangeError: Maximum call stack size exceeded error when creating and when typing. One user reported that this caused his entire code block to be erased and he couldn't get it back using Undo
To make sure this wasn't something in my program causing this I made a completely barebones empty project with electron, prosemirror-example-setup, prosemirror-highlightjs(0.7.1), and highlightjs(11.2.0) and it does the same thing.
The solution on my end was to disable the autohighlightCallback all together in getHighlightDecorations.ts:
// if we autohighlighted and have a callback set, call itif(!language&&options?.autohighlightCallback){// COMMENTING OUT THIS LINE // options.autohighlightCallback(b.node, b.pos, result.language);}
Here's the error message:
C:\Users\jcv8000\Desktop\hljstest\node_modules\highlight.js\lib\core.js:2184 Uncaught RangeError: Maximum call stack size exceeded
at Array.sort (<anonymous>)
at Object.highlightAuto (C:\Users\jcv8000\Desktop\hljstest\node_modules\highlight.js\lib\core.js:2184)
at C:\Users\jcv8000\Desktop\hljstest\node_modules\prosemirror-highlightjs\dist\index.js:1
at Array.forEach (<anonymous>)
at r (C:\Users\jcv8000\Desktop\hljstest\node_modules\prosemirror-highlightjs\dist\index.js:1)
at d (C:\Users\jcv8000\Desktop\hljstest\node_modules\prosemirror-highlightjs\dist\index.js:1)
at Plugin.apply (C:\Users\jcv8000\Desktop\hljstest\node_modules\prosemirror-highlightjs\dist\index.js:1)
at EditorState.applyInner (C:\Users\jcv8000\Desktop\hljstest\node_modules\prosemirror-state\dist\index.js:871)
at EditorState.applyTransaction (C:\Users\jcv8000\Desktop\hljstest\node_modules\prosemirror-state\dist\index.js:835)
at EditorState.apply (C:\Users\jcv8000\Desktop\hljstest\node_modules\prosemirror-state\dist\index.js:811)
The text was updated successfully, but these errors were encountered:
I was unable to reproduce the issue you describe locally. Can you perhaps give me some more info on your setup or a sample project + input that is giving this issue? I'm also a tad surprised that commenting out the autohighlightCallback did the trick for you, since the exception log you posted has the stack overflow happening in the highlight.js library, not mine.
Either way, I did some diving in my code around this line and came up with a fix for an issue that seems like it might happen in theory, but I couldn't actually get to trigger locally. The theory I came up with was that if hljs.autoHighlight returns no language, then autohighlightCallback triggers, updates the prosemirror node with an empty language param, which triggers a redraw, which calls the callback with an empty language, which triggers an update/redraw... and so forth.
Can you check to see if the fix included in version 0.7.2 fixes your issue? If not, please provide a sample setup so I can dig into this a bit more.
The pm-example-setup.js file is a direct copy of the prosemirror-example-setup package's dist/index.js with highlightPlugin added to the plugins list. pm-schema.js is a copy of the basic schema, I just added the hljs class to the code block node
My users and I noticed this issue in my program Codex, that when you create a code block with a language it works fine, but when you create a code block with no language to be auto-highlighted, it freezes the program for 10+ seconds and spits out an
Uncaught RangeError: Maximum call stack size exceeded
error when creating and when typing. One user reported that this caused his entire code block to be erased and he couldn't get it back using UndoTo make sure this wasn't something in my program causing this I made a completely barebones empty project with electron, prosemirror-example-setup, prosemirror-highlightjs(0.7.1), and highlightjs(11.2.0) and it does the same thing.
The solution on my end was to disable the
autohighlightCallback
all together ingetHighlightDecorations.ts
:Here's the error message:
The text was updated successfully, but these errors were encountered: