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

node sometimes hangs when NODE_V8_COVERAGE is set #1074

Open
4 of 5 tasks
jhayes-dev opened this issue Mar 10, 2023 · 4 comments
Open
4 of 5 tasks

node sometimes hangs when NODE_V8_COVERAGE is set #1074

jhayes-dev opened this issue Mar 10, 2023 · 4 comments
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@jhayes-dev
Copy link

Software versions

  • OS: Amazon Linux 2 and node:gallium docker image
  • Consumer Pact library: pact@11.0.2
  • Provider Pact library: e.g. pact-jvm-provider-maven_2.11 v 3.3.8
  • Node Version: v16.19.1

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behavior

Node should not hang when generating coverage data while using pact.

Actual behavior

Depending on how many tests I run, node hangs when writing the coverage data.

Steps to reproduce

See the attached zip file,
test-pact-hang.zip, with a docker-compose.yml and Dockerfile that reproduce the problem. When you run docker compose up --build node hangs using 100% CPU and 7.2GB RAM. Node does not hang when NODE_V8_COVERAGE is not set in the docker-compose file. Uncommenting global.gc(); in test-pact.js prevents the hang when NODE_V8_COVERAGE is set.

Relevant log files

See logs.txt in the zip file.

@jhayes-dev jhayes-dev added the bug Indicates an unexpected problem or unintended behavior label Mar 10, 2023
@mefellows
Copy link
Member

Thanks for this, one guess would be something to do with how we use native libraries using the N-API. I'd have to look up if there are practices required to make it work.

Did you get into any analysis as to where the hang is happening? Does it happen outside of docker also?

Also I'm assuming you can run the same instrumentation on a non-Pact project and it works as expected?

@jhayes-dev
Copy link
Author

I uncovered the hang on our Jenkins server running Amazon Linux 2. The tests run fine on macOS with NODE_V8_COVERAGE set.

At first I thought it could be linux+limited RAM problem because top showed node using 11GBs of RAM on Jenkins. I tried it in docker because I could easily limit resources allocated to the process and I could test it on my Mac.

This project defines 6 consumer interaction and 3 other tests. The hang does not manifest when only running the Pact interactions. We get valid coverage data when running the non-Pact tests. The tests define the Pact object even when the Pact tests are skipped if that maters.

I was surprised I had iterate 100 times to get it to hang in the test script.

@mhofman
Copy link

mhofman commented May 5, 2023

FYI we ran into the same issue with Ava. I worked around it by patching ava to call v8.takeCoverage() before its worker exits.

@mefellows mefellows added triage This issue is yet to be triaged by a maintainer and removed Triage labels Jul 12, 2023
@YOU54F
Copy link
Member

YOU54F commented Jun 10, 2024

i believe a fix had landed in node 20 that will resolve this and was backported to node 18

thanks @mhofman for tracking.

nodejs/node#51290 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants