Skip to content

Conversation

@rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Feb 13, 2025

On GitHub Actions the jest test run doesn't exit because it is being kept alive.

The reason is that we create a CloudWatchLogMonitor in one test, which keeps on scheduling a timer with setTimeout() which keeps the Node process alive. I'm not sure why this doesn't manifest on the CodeBuild build or a Mac laptop run, but it can be somewhat reproduced by running npx jest --detectOpenHandles, which does make the test hang on Mac as well.

I considered unref()fing the timer, but it seems a smaller and therefore safer change to take the CloudWatchLogMonitor and deactivate it.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

On GitHub Actions the `jest` test run doesn't exit because it is being
kept alive.

The reason is that we create a `CloudWatchLogMonitor` in one test, which
keeps on scheduling a timer with `setTimeout()` which keeps the Node
process alive.

I considered `unref()`fing the timer, but it seems a smaller and
therefore safer change to take the `CloudWatchLogMonitor` and deactivate
it.
@rix0rrr rix0rrr requested a review from a team February 13, 2025 09:11
@github-actions github-actions bot added the p2 label Feb 13, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team February 13, 2025 09:12
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 13, 2025
@codecov
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.90%. Comparing base (efb5a34) to head (6297703).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33427   +/-   ##
=======================================
  Coverage   80.90%   80.90%           
=======================================
  Files         236      236           
  Lines       14261    14261           
  Branches     2493     2493           
=======================================
  Hits        11538    11538           
  Misses       2438     2438           
  Partials      285      285           
Flag Coverage Δ
suite.unit 80.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 79.74% <ø> (ø)
packages/aws-cdk-lib/core 82.16% <ø> (ø)

}));

// Deactivate the cloudWatchLogMonitor that we created, otherwise the tests won't exit
(deploySpy.mock.calls[0][2] as any).cloudWatchLogMonitor?.deactivate();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be in a finally block then?

Copy link
Contributor Author

@rix0rrr rix0rrr Feb 13, 2025

Choose a reason for hiding this comment

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

We can only get a reference to the right object if the get far enough that the call succeeds and we can dig the object out of the call sequence.

So if we break this test the experience won't be great... but in that case we're broken anyway

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, would be nice to make the broken experience better though. Won't insist.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the way cloud watch logs monitoring is currently implemented makes a lot of sense for the toolkit. I'm currently making my way through the deploy action and can take a look.

@mergify
Copy link
Contributor

mergify bot commented Feb 13, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 6297703
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Feb 13, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 23c912f into main Feb 13, 2025
20 checks passed
@mergify mergify bot deleted the huijbers/tests-dont-exit branch February 13, 2025 10:28
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants