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

Jest reports open handles when running E2E #10199

Open
aaemnnosttv opened this issue Feb 10, 2025 · 0 comments
Open

Jest reports open handles when running E2E #10199

aaemnnosttv opened this issue Feb 10, 2025 · 0 comments
Labels
P1 Medium priority QA: Eng Requires specialized QA by an engineer Team M Issues for Squad 2 Type: Infrastructure Engineering infrastructure & tooling

Comments

@aaemnnosttv
Copy link
Collaborator

aaemnnosttv commented Feb 10, 2025

Bug Description

> test:e2e
> cross-env WP_BASE_URL=http://localhost:9002 ./script.js "specs/api-cache"

**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" was set in project config.
 PASS  specs/api-cache.test.js (16.158 s)
  API cache
    ✓ isolates client storage between sessions (5682 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        16.282 s
Ran all test suites matching /specs\/api-cache/i.
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

Note the last line above

Running with --detectOpenHandles found the cause related to dependencies used by Dockerode.

Ran all test suites matching /specs\/api-cache/i.

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  ZLIB

      at Object.<anonymous> (../../node_modules/ssh2/lib/protocol/zlib.js:17:20)
      at Object.<anonymous> (../../node_modules/ssh2/lib/protocol/kex.js:48:5)

Steps to reproduce

  1. Run an E2E test that does not produce any output to the WP container log stream (e.g. specs/api-cache)

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Jest warnings about open handles following E2E test runs are resolved

Implementation Brief

Test Coverage

  • No changes

QA Brief

  • This can be verified locally as it isn't visible in CI since it runs over all tests which causes the log to be populated at some point
  • A simple test which can be used is to run npm run test:e2e -- specs/api-cache
    • This tests the happy path (no logs recorded)
    • To test this with log output, run the same with a small temporary modification to ensure the PHP log is written to during this test:
diff --git a/tests/e2e/mu-plugins/e2e-rest-time-endpoint.php b/tests/e2e/mu-plugins/e2e-rest-time-endpoint.php
index 912769d58b..abcd412266 100644
--- a/tests/e2e/mu-plugins/e2e-rest-time-endpoint.php
+++ b/tests/e2e/mu-plugins/e2e-rest-time-endpoint.php
@@ -24,6 +24,7 @@ add_action(
 			array(
 				'methods'             => WP_REST_Server::READABLE,
 				'callback'            => function () {
+					error_log( time() );
 					return array(
 						'time'      => time(),
 						'microtime' => microtime( true ),

You should be able to verify the additions to the logs by inspecting the wordpress-debug-log-1 container logs in Docker, but also, the test would be expected to fail due to this triggering our assertions (working correctly)

Changelog entry

@aaemnnosttv aaemnnosttv added P1 Medium priority Type: Bug Something isn't working labels Feb 10, 2025
@aaemnnosttv aaemnnosttv self-assigned this Feb 10, 2025
@aaemnnosttv aaemnnosttv added Type: Infrastructure Engineering infrastructure & tooling and removed Type: Bug Something isn't working labels Feb 11, 2025
@aaemnnosttv aaemnnosttv removed their assignment Feb 11, 2025
@ivonac4 ivonac4 added the Team M Issues for Squad 2 label Feb 11, 2025
@tofumatt tofumatt assigned tofumatt and unassigned tofumatt Feb 11, 2025
@techanvil techanvil assigned techanvil and unassigned techanvil Feb 12, 2025
@techanvil techanvil added the QA: Eng Requires specialized QA by an engineer label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 Medium priority QA: Eng Requires specialized QA by an engineer Team M Issues for Squad 2 Type: Infrastructure Engineering infrastructure & tooling
Projects
None yet
Development

No branches or pull requests

4 participants