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.

react-dev-overlay ally.js causes MutationObserver infinite loop

See original GitHub issue

Bug report

Describe the bug

react-dev-overlay uses ally.js, which registers and responds to DOM mutations using a MutationObserver. If other MutationObservers are present, this can yield an infinite loop of mutation observing and mutating.

Specifically, in my case, I am using ProseMirror, which also observes the DOM. When the overlay opens and a ProseMirror instance is present, an infinite loop occurs.

Here’s how it goes:

1 - The overlay initializes in a useEffect. As part of its initialization, it mutates the DOM

Screen Shot 2020-09-14 at 11 33 39 PM

2 - ProseMirror detects this mutation, and mutates the DOM too,

Screen Shot 2020-09-14 at 11 34 11 PM

3 - ally.js’s MutationObservers detect the mutation, and perform their own mutations

Screen Shot 2020-09-14 at 11 34 41 PM

And round and round it goes from there… every time I get an error on this route, I have to kill the tab in task manager! It’s really painful. Now that I’ve identified the error, I think I might edit node_modules to disable the underlying cause, but a proper solution would be great.

Thank you!

System information

  • Version of Next.js: [e.g. 6.0.2] 9.5.3

Update

Indeed, commenting the ally initialization code from the useEffect in overlay resolves the issue locally.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dminkovskycommented, Jan 5, 2021

@Timer @lachlanjc Yes, this issue is gone in 10.0.5-canary.9. Thanks again!

1reaction
Timercommented, Jan 1, 2021

This should be fixed in next@^10.0.5-canary.7, please give it a try!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mutation Observer causing infinite loop - Stack Overflow
I'm trying to modify the images of a website that uses react and takes the images via API and generates a gallery with...
Read more >
开发工具 - 超级架构师
Ramda - Utility library with a focus on flexible functional composition enabled by automatic currying and reversed argument order. Avoids mutating data.
Read more >
MutationObserver - Web APIs | MDN
Creates and returns a new MutationObserver which will invoke a specified callback function when DOM changes occur. Instance methods. disconnect ...
Read more >
Getting To Know The MutationObserver API
In complex web apps, DOM changes can be frequent. As a result, there are instances where your app might need to respond to...
Read more >
This Is Unbelievably Powerful - YouTube
Mutation Observer is an amazing tool in JavaScript that allows you to easily and efficiently observe any form of DOM changes.
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