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

ci stuck #462

Closed
woldtwerk opened this issue May 2, 2022 · 7 comments · Fixed by #469
Closed

ci stuck #462

woldtwerk opened this issue May 2, 2022 · 7 comments · Fixed by #469
Assignees
Labels
bug Something isn't working high priority

Comments

@woldtwerk
Copy link

woldtwerk commented May 2, 2022

I updated from ^2.55.0 to latest and this causes my github pipeline to get stuck after the tests are done. Oddly enough it works on windows. only linux and macos get stuck.

Am I overseeing something in the upgrade notes which can cause this?

I'm using vitest for testing.

link to repo:
https://github.com/ueberbit/lib

image

@tapioko
Copy link

tapioko commented May 3, 2022

I probably have the same issue, although I use Windows 10 (21H2). Works fine with version 2.55.0, gets randomly stuck with 3.0.0. I also use vitest (0.10.2) for testing.

To reproduce, create at least three test files like this:

import { describe, expect, it } from 'vitest';

describe('suite name', () => {
    it('foo', () => {
        expect(1 + 1).toEqual(2);
    });
});

Then run tests with "npx vitest". Press enter many times until it gets stuck. The more test cases or tests files there are, the sooner it will get stuck (probably takes less than 10 retries).

My minimal vite.config.ts:

import { defineConfig } from 'vitest/config';

export default defineConfig({
    test: {
        environment: 'happy-dom',
    },
});

@dennismphil
Copy link

dennismphil commented May 3, 2022

I have this same issue as well with 3.1.0. When I downgrade to 2.55.0 it works.  

My pnpm coverage command hangs on local mac. I am using c8 for coverage reporting  

// package.json

 "scripts": {
  ..
  ..
  "coverage": "c8 --check-coverage --lines 80 --functions 100 pnpm test",
  "test": "vitest run",
  ..
  ..

@capricorn86 capricorn86 added bug Something isn't working high priority labels May 4, 2022
@capricorn86 capricorn86 self-assigned this May 4, 2022
@capricorn86
Copy link
Owner

Thank you for reporting @woldtwerk, @tapioko and @dennismphil! 🙂

I believe that I have localized the problem. It is a bit problematic to fix as "Window" now is running as a as a VM context and Vitest is importing it and sets its keys in the global context.

There is a new class called GlobalWindow, which is meant to be executed in the global context.

It was not expected that Vitest imported Happy DOM this way and I wish I knew this before the major release was made. The change was done to solve multiple bugs/problems when running things with Happy DOM in a VM.

To solve this either Vitest needs to import GlobalWindow and use it instead, or Happy DOM needs to change Window to be the global window and make a new class called VMWindow (or similar).

@capricorn86
Copy link
Owner

It seems like Vitest will fix it on their side 🙂

capricorn86 pushed a commit that referenced this issue May 5, 2022
…as caused by the import of the package "sync-request".
capricorn86 added a commit that referenced this issue May 5, 2022
#462@patch: Fixes problem with Vitest hanging in some scenarios. It w…
@capricorn86
Copy link
Owner

@woldtwerk, @tapioko and @dennismphil apparently the problem was not what I thought, even though it might cause other problems.

After some more debugging I found the problem. It was caused by the import of "sync-request". I have now made a fix.

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v3.1.1

@woldtwerk
Copy link
Author

Thx for the quick fix. Works like a charm again:

image

@capricorn86
Copy link
Owner

Great to hear @woldtwerk! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants