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

@vitest/coverage-v8@1.3.1 hangs indefinitely with Nestjs #5252

Closed
6 tasks done
noahw3 opened this issue Feb 20, 2024 · 5 comments · Fixed by #5259
Closed
6 tasks done

@vitest/coverage-v8@1.3.1 hangs indefinitely with Nestjs #5252

noahw3 opened this issue Feb 20, 2024 · 5 comments · Fixed by #5259
Labels
feat: coverage Issues and PRs related to the coverage feature p3-significant High priority enhancement (priority)

Comments

@noahw3
Copy link

noahw3 commented Feb 20, 2024

Describe the bug

Using the @vitest/coverage-v8 package with the latest version hangs while mocking a project using nestjs. Output prints JUNIT report written to [path]/coverage/unit/junit.xml and then the process does not exit, with no coverage report being output. This does not occur as of version 1.3.0. I'm guessing that it has something to do with the changes made to decorators in #5206, as Nest makes heavy use of decorators.

Reproduction

Technically this version does resolve after hanging for ~30 seconds, but hopefully that should be enough to highlight the issue.

https://github.com/noahw3/vitest/tree/main/examples/basic

System Info

We also observed this in our CI environment, though it also reproduced locally.

  System:
    OS: macOS 14.1.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 623.30 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
    pnpm: 8.10.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 121.0.6167.184
    Safari: 17.1.2
  npmPackages:
    @vitest/coverage-v8: 1.3.1 => 1.3.1 
    vitest: 1.3.1 => 1.3.1

Used Package Manager

pnpm

Validations

@AriPerkkio
Copy link
Member

Does it hang with @vitest/coverage-istanbul or without coverage?

@wataruian
Copy link

wataruian commented Feb 21, 2024

It hangs with @vitest/coverage-v8 for me, I am not sure about istanbul. Disabling coverage, the tests succeeds.

@AriPerkkio
Copy link
Member

AriPerkkio commented Feb 21, 2024

I can reproduce the hang. Something as simple as removing , from this regexp fixes the issue. Looks like Regexr is also reporting this as slow matcher: https://regexr.com/7salk

const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes"(\s|.)+?]\),/g

-const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes"(\s|.)+?]\),/g
+const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes"(\s|.)+?]\)/g

Could you @noahw3 or @wataruian try if that fixes the hangs in real world Nestjs project by modifying the node_modules/@vitest/covearge-v8.

@AriPerkkio AriPerkkio added feat: coverage Issues and PRs related to the coverage feature p3-significant High priority enhancement (priority) and removed pending triage labels Feb 21, 2024
@wataruian
Copy link

@AriPerkkio removing the , works on my end.

@noahw3
Copy link
Author

noahw3 commented Feb 21, 2024

Yes, can confirm that adjusting the regex no longer hangs in my full project.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: coverage Issues and PRs related to the coverage feature p3-significant High priority enhancement (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants