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

http2.Http2Server listen conditionally leaves an open file handle after cleanup #47006

Open
jason-gigastar opened this issue Mar 8, 2023 · 2 comments
Labels
http2 Issues or PRs related to the http2 subsystem.

Comments

@jason-gigastar
Copy link

jason-gigastar commented Mar 8, 2023

Version

18.14.0

Platform

Linux 5.14.0-1045-oem #51-Ubuntu SMP Mon Jul 4 06:41:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

node:http2

What steps will reproduce the bug?

Given the following Jest test suite, replace test with test.only and run each scenario in isolation.

import http2 from 'node:http2';

function verifyListen(host: string | undefined): void {
    const server = http2.createServer({});
    server.listen(8888, host);
    server.close();
}

describe.only('HttpServer', () => {
    test('good scenario', () => {
        console.log('good scenario');
        verifyListen(undefined);
    });

    test('bad scenario 1', () => {
        console.log('bad scenario 1');
        verifyListen('localhost');
    });

    test('bad scenario 2', () => {
        console.log('bad scenario 2');
        verifyListen('127.0.0.1');
    });
});

Jest command:
npx jest --testRegex test/BugReport.ts --detectOpenHandles

There are no connections being created, just listen on the port and then close the port.

How often does it reproduce? Is there a required condition?

Always when localhost or 127.0.0.1 are used.

What is the expected behavior?

When close is called there should be no open handles after all connections complete. In the simplest case there are no connections needed to cleanup and still there's an open handle.

What do you see instead?

The good scenario runs without problems.

The 2 bad scenarios, when run in isolation, both yield:

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

  ●  TCPSERVERWRAP

      3 | function verifyListen(host: string | undefined): void {
      4 |     const server = http2.createServer({});
    > 5 |     server.listen(8888, host);
        |            ^
      6 |     server.close();
      7 | }
      8 |

Additional information

No response

@VoltrexKeyva VoltrexKeyva added the http2 Issues or PRs related to the http2 subsystem. label Mar 8, 2023
@ywave620
Copy link
Contributor

Could you tell what the jest version is in use?

@jason-gigastar
Copy link
Author

Jest 29.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants