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.

Stuck in endless loop (crashes browser)

See original GitHub issue

Hey Guys,

I’m using the convertToHTML method and I managed to get stuck into an endless loop with it, that crashes the browser. Just wanted you to be aware of it.

This is how I used it:

import{ convertToHTML } from "draft-convert";
const html = convertToHTML(this.state.editorState.getCurrentContent());

The only special thing I do before calling this method was to initialize Draft.js with a raw document ({blocks: [...], entityMap: {}}) that I had stored in my DB (contains bulletpoints). Like this:

var jsonFromDB = {blocks: [...], entityMap: {}};
var blocks = convertFromRaw(jsonFromDB);
var editorState = EditorState.createWithContent(
     blocks, decorator
);

this.setState({
    editorState: editorState,
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
roundrobincommented, Dec 10, 2017

yeah sorry for not being super helpful yet. I’m going to take the time to reproduce this issue in a JSFiddle next week. My hunch is that the while-loop in convertToHTML is never exiting in this scenario.

0reactions
benbriggscommented, Dec 12, 2017

i think it’d be odd to throw one for that instance without validating the entire structure (which i think is pretty far outside the charter of this project). additionally, i’d expect that these differences are going to cause issues not just with draft-convert but with core draft-js functionality, such as this operation. i think its fair for this project to make the same amount of assumptions as draft-js and have undefined behavior for invalid input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you stop an infinite loop? Tutorial crashed my browser ...
press (ctrl + shift + esc) if on windowsOS to open the task manager then right click your browser icon Chrome ,fireFox and...
Read more >
Why does an infinite loop crash the browser? - Reddit
An infinite loop can simply freeze the browser or can crash it, depending on how the code is looped. A simple loop will...
Read more >
Browser stuck in infinite loop. - Codecademy
Hello, whenever I try to access 10/12 of jQuery event my browser get stuck in an infinite loop and is never able to...
Read more >
Google Chrome gets stuck in a loop
The tab that I'm on crashes and after a few seconds my browser is ready to use again. However, this seems like a...
Read more >
Debugging Infinite Loops | CodeHS Knowledge Base
Often, when a program is run and the browser becomes unresponsive and crashes, this means that your student's program contains an infinite loop....
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