Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uncaught DOMException error #1752

Merged
merged 3 commits into from
Feb 20, 2020
Merged

Conversation

sdb1228
Copy link
Contributor

@sdb1228 sdb1228 commented Feb 16, 2020

This should fix #1751 :)

@alexreardon
Copy link
Collaborator

When can this happen?

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 16, 2020

Hey @alexreardon! This happens when the dom is cycled out before pretty dnd can unmount (aka this settimeout get executed)

@alexreardon
Copy link
Collaborator

When did you run into this? I'm guessing in a testing environment?

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 16, 2020

Oh! Sorry didn't understand what you meant. I actually ran into this in my development and staging environment on the app I work on. We use Turbo links and sentry had caught this error when someone was navigating away from a react page that had react-beautiful-dnd on it.

@alexreardon
Copy link
Collaborator

@alexreardon
Copy link
Collaborator

I am thinking we might want to add a test to ensure that we don't break people doing things like this

@alexreardon
Copy link
Collaborator

For now I'm trying to understand what can cause the issue to occur

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 16, 2020

Yup! thats the library. I can totally add a test. I can try to find a way to reproduce it. I was thinking that you could probably experience this if you used something like react-routter ( https://github.com/ReactTraining/react-router) potentially, but I think the easiest way to trigger this would be to unmount a root level react component at the same time as rendering a full new dom tree so that the timeout happens after the new page is rendered. I couldn't think of an easy way to reproduce it without spinning up a full rails app with turbo links and everything, but if we really want me to do that I totally can. In the mean time ill work on writing some tests. :)

@alexreardon
Copy link
Collaborator

I think the easiest way to trigger this would be to unmount a root level react component at the same time as rendering a full new dom tree so that the timeout happens after the new page is rendered

Let's add a test for that as I think it is the underlying technique

@alexreardon
Copy link
Collaborator

Can you please add a test in unit/integration?

@alexreardon
Copy link
Collaborator

(all the tests are moving over to there - all that folder uses react-testing-library)

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 16, 2020

Yup! I can totally do that.

getBodyElement().removeChild(el);

// checking if element exists before remove to prevent errors
if (getBodyElement().contains(el)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked - this is all good for ie11

https://developer.mozilla.org/en-US/docs/Web/API/Node/contains

@alexreardon
Copy link
Collaborator

Let me know when you would like me to take a look. Keep to get this in for v13!

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 18, 2020

Getting on this this morning! should hopefully have tests up before lunch

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 18, 2020

Hey @alexreardon it looks like there is a spec already in test/unit/view/announcer.spec.js:50 that does exactly what I would need to do just need to modify it a little. You okay if I just add another spec next to it or would you like me to migrate both tests over to that other directory?

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 18, 2020

I pushed up the test and put it in the same file. It has react testing lib in there already I hope that is okay. Let me know if you want me to move it.

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 18, 2020

And it now has passed all checks. Let me know if there is anything else you would like me to do!

@alexreardon
Copy link
Collaborator

I am hoping to release 13.x soon and it would be good to get this in. Any chance you will have an opportunity to look at this soon?

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 19, 2020

Thanks for verifying! I can't merge because its a protected branch and I am not authorized to do so. Never had this happen to me before so let me know what you need me to do on my side @alexreardon

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 19, 2020

and I just realized that we are going to be in completely different time zones lol. Ill stay by my phone to merge this but let me know how I can merge into the branch that is protected. Ill google around to see if I can figure it out in the mean time.

@alexreardon
Copy link
Collaborator

I can't merge

I can do the merging once the PR is ready to go

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 19, 2020

Any chance you will have an opportunity to look at this soon?

Awesome! So maybe I missed it is there some feedback I need to address?

@alexreardon
Copy link
Collaborator

It looks good, i'll merge it very soon

@alexreardon alexreardon merged commit 95e465e into atlassian:master Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cleanup settimeout throws error if dom element isn't on page.
2 participants