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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latest version of Happy DOM hangs Vitest #1233
Comments
Thank you very much for your reference! We saw that we had a problem with new version of happy-dom, but didn鈥檛 have time to dig in. This will surely help us fix the issues 馃槃 I think we can just check for GlobalWindow, and use it. If it doesn鈥檛 exist, fallback to Window. This should work with both versions, I guess? |
@sheremet-va yes that should solve the issue for both versions 馃檪 馃憤 |
@capricorn86 unfortunately simple Maybe you have other ideas why this might happen? |
@sheremet-va I have now debugged and apparently the import of a package called "sync-request" caused the issue. Not sure what is happening, but I will make a fix for it as soon as possible in Happy DOM. I still suggest changing to use GlobalWindow instead of Window as other problems could emerge otherwise. |
There is now a fix available in the latest version of Happy DOM (v3.1.1) 馃檪 |
It seems, it still fails on Node 16 on Windows 馃 https://github.com/vitest-dev/vitest/runs/6309436372?check_suite_focus=true Edit: Hm, on the third rerun it passed 馃 |
Weird 馃 I only tested in the project mentioned above where it hanged and there the fix solved the problem, but I can try to debug with the test you ran as well. |
Maybe it was just a fluke. We released the fix in 0.10.4, let's see how it will play out 馃槃 |
Yes, hopefully! 馃槄 It works now for the consumers that reported the problem in Happy DOM at least. |
Describe the bug
First I just want to say that this is a great library and I have recommended it to a lot of people. It is also really fun that Happy DOM is used as I am the creator of it 馃檪
I just released a new major version of Happy DOM, which I believe is causing Vitest to hang in some scenarios.
In the latest major version of Happy DOM, the Window object is a VM context. This means that global keys like Object, Array, Function etc. in the Window instance are unique to the context and will not be the same as in the global object. The change was done to solve multiple problems reported to Happy DOM.
Now when I looked at the Vitest code I noticed that the keys from the Window instance are copied to the global object. It will then override native properties (like Object, Arrray, Function etc.) with another version unique to the VM context. This will probably cause all kinds of weird behaviors.
I wish I knew that Vitest imported Happy DOM this way. I would have handled the release differently then 馃槄
Happy DOM now exports a class called GlobalWindow, which is meant to be executed within the global context.
To solve the problem either Vitest changes to use GlobalWindow, or Happy DOM changes Window to be the global window and creates a new window class called VMWindow (or similar).
Bug in Happy DOM:
capricorn86/happy-dom#462
Reproduction
Reproduce global reference issues
This will fail:
Reproduce Vitest hanging
In the issue in Happy DOM several users described scenarios where just a few tests had to be run for it to happen, but I was only able to reproduce it consistently in:
https://github.com/ueberbit/lib
To reproduce:
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: