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.

JsDiff.diffWords in Rollback freezes browser

See original GitHub issue

After a deploy we somehow accidentally messed up our homepage. When trying to rollback to the last working version, the browser kept freezing up.

After diving into the code, I noticed that the point where the code started to hang was when it tried to call JsDiff.diffWords(property.value, oldProperty.value), obviously used to display the changes between the two version.

However, we have one very big Grid on this page, resulting in an oldProperty.value size of 2.3MB! JsDiff.diffWords cannot handle this size and will freeze up (especially considering the property.value at this point in time was near-empty, so the percentage of difference was insane).

Eventually, I managed to skip the diffing by replacing the function with a stub in the console: JsDiff.diffWords=function(a, b, c) { return undefined; }; and could successfully rollback the page.

I think there needs to be some sort of fail-safe in the whole diffing process. Either by truncating the data if it goes over a certain limit, or skipping it all together with a nice message why.

EDIT: Upon investigating, the Grid itself was not so big. It’s all the stuff around it that virtually inflates the property value. The Grid itself contains like 10 sections and maybe 30 grid components in total. The actual property blows up in size because it’s constantly repeating all the grid components in $allowedEditors (and we have a lot of them) and the full editor inside each placed grid component (and our grid components have a lot of configuration).

So besides JsDiff.diffWords needing a fail-safe, the value-format stored by the Grid datatype is HIGHLY inefficient, so that might be an issue all on its own.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
nul800sebastiaancommented, Nov 12, 2020

Using diffJson seems to take us a long way, it immediately alleviates all the stuff we store as JSON. I’ve made a PR here to evaluate, please try it out and let us know how it goes! https://github.com/umbraco/Umbraco-CMS/pull/9381

1reaction
lars-erikcommented, Nov 12, 2020

#9381 makes a diff take 20 seconds where it previously froze the browser for 30+ min.
I say merge! 🎉❤

Highest of fives
(should say send instead of request, but it’s the highest!)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using rollback on nodes with a medium/large grid, makes ...
It seems that the browser crashes because of the huge amount of DOM elements that is created as a result of the rollback....
Read more >
How to avoid freezing the browser when doing long- ...
I have a web page where a javascript calculation in a function takes lot of time to finish and makes the page to...
Read more >
2702747-2.patch
What browser(s) and/or Node.js versions experience the problem? ... for browser testing + * ignore: update ignore files for component support + *...
Read more >
Code coverage report for node-npmtest-mocha ...
This is useful when running tests in a browser because window.onerror will * only receive the 'message' attribute of the Error. */ mocha....
Read more >
clarinet @ 0.11.0 .. 0.12.3 - Package Diff
Visual diff of the npm package 'clarinet' comparing 0.11.0 with 0.12.3.
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