question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: syncYjsChangesToLexical unable to find active editor in headless mode

See original GitHub issue

I am currently working on converting the representation of lexical in yjs to html. I received a very helpful gist when I initially enquired about this in discord. Whilst working on implementing this, I have come across an issue using the syncYjsChangesToLexical method. The stack trace of the error is as follows:

 Error: Unable to find an active editor. This method can only be used synchronously during the callback of editor.update().
[0]     at getActiveEditor (C:<project 
-path>\node_modules\lexical\Lexical.dev.js:5541:13)
[0]     at $setNodeKey (C:<project 
-path>\node_modules\lexical\Lexical.dev.js:550:18)
[0]     at new LexicalNode (C:<project 
-path>\node_modules\lexical\Lexical.dev.js:6334:5)
[0]     at new ElementNode (C:<project 
-path>\node_modules\lexical\Lexical.dev.js:7077:5)
[0]     at new LinkNode (C:<project 
-path>\node_modules\@lexical\link\LexicalLink.dev.js:33:5)
[0]     at createLexicalNodeFromCollabNode (C:<project 
-path>\node_modules\@lexical\yjs\LexicalYjs.dev.js:336:23)
[0]     at CollabElementNode.syncChildrenFromYjs (C:<project 
-path>\node_modules\@lexical\yjs\LexicalYjs.dev.js:847:34)
[0]     at createLexicalNodeFromCollabNode (C:<project 
-path>\node_modules\@lexical\yjs\LexicalYjs.dev.js:345:16)
[0]     at CollabElementNode.syncChildrenFromYjs (C:\<project 
-path>\node_modules\@lexical\yjs\LexicalYjs.dev.js:847:34)
[0]     at syncEvent (C:<project 
-path>\node_modules\@lexical\yjs\LexicalYjs.dev.js:1523:18)

This errror does not occur when the editor contains simple text. Once I start using more sophisticated nodes such as links and tables, the error is thrown.

Lexical version: 0.6.0

Steps To Reproduce

  1. Create a nodejs project
  2. implement a headless editor using jsdom
  3. Try to generate html from yjs doc

An example of code to reproduce this is shown below.

Link to code example:

A gist containing a modified version of the gist provided previously can be found here.

The current behavior

As mentionned above, when generating html which only contains text, this works as expected. When generating html which contains nodes such as tables and links, an error with the stack trace above is shown.

The expected behavior

I would expect that the behaviour is the same for both text nodes and other nodes.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
trueadmcommented, Dec 19, 2022

It’s still single threaded so yes it should be fine.

1reaction
trueadmcommented, Dec 19, 2022

You really can’t use two separate lexicals. You must keep it to one as those variables may seem “global” but they’re actually lexicallly bound to the lexical source (one of the reasons it’s called Lexical). Can you avoid duplicating lexical in your env?

Read more comments on GitHub >

github_iconTop Results From Across the Web

webdriver.chrome.driver in headless mode can't find element
Given xpath belongs to an input field, which opens a file selector when clicked. It is working perfectly in a normal Firefox.
Read more >
Unable start Chrome in headless mode - Stack Overflow
A few possible issues: First, you mention that you are on WSL2, but the Chrome error you are receiving leads me to believe...
Read more >
334576 – Headless runs detect that org.eclipse.ui is active, a ...
In bug# 309781 we introduced a check to see if org.eclipse.ui was active in headless mode, this check seems to be unreliable and...
Read more >
Facebook Lexical Statistics & Issues - Codesti
Facebook Lexical: Lexical is an extensible text editor framework that provides excellent ... Bug: Unable to find an active editor in headless mode,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found