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: crypto hash functions leak cryptoDigest resources in tests #18140

Closed
zookatron opened this issue Mar 12, 2023 · 0 comments · Fixed by #18229
Closed

node: crypto hash functions leak cryptoDigest resources in tests #18140

zookatron opened this issue Mar 12, 2023 · 0 comments · Fixed by #18229
Assignees
Labels
bug Something isn't working node compat

Comments

@zookatron
Copy link

zookatron commented Mar 12, 2023

Reproduction example:

Deno version:

deno 1.31.2 (release, x86_64-unknown-linux-gnu)
v8 11.0.226.19
typescript 4.9.4

mod.ts:

import PG from "npm:pg@8.10.0";

export async function test() {
  const client = new PG.Client({connectionString: Deno.env.get("DATABASE_URL")});
  await client.connect();
  await client.end();
}

mod.test.ts:

import { test } from "./mod.ts";

Deno.test("Test", async () => {
  await test();
});

Run:

deno test --allow-net --allow-env

Expected output:

ok | 1 passed | 0 failed (53ms)

Actual Output:

error: AssertionError: Test case is leaking 4 resources:

 - A "cryptoDigest" resource (rid 8196) was created during the test, but not cleaned up during the test. Close the resource before the end of the test.
 - A "cryptoDigest" resource (rid 8200) was created during the test, but not cleaned up during the test. Close the resource before the end of the test.
 - A "cryptoDigest" resource (rid 8203) was created during the test, but not cleaned up during the test. Close the resource before the end of the test.
 - A "cryptoDigest" resource (rid 8206) was created during the test, but not cleaned up during the test. Close the resource before the end of the test.

    at assert (ext:deno_web/00_infra.js:353:11)
    at resourceSanitizer (ext:cli/40_testing.js:417:5)
    at async Object.exitSanitizer [as fn] (ext:cli/40_testing.js:435:7)
    at async runTest (ext:cli/40_testing.js:840:5)
    at async runTests (ext:cli/40_testing.js:1098:20)

FAILED | 0 passed | 1 failed (258ms)

The cause of the issue appears to be the use of the node crypto library for hashing in the pg library, see for example https://github.com/brianc/node-postgres/blob/master/packages/pg/lib/sasl.js#L194 If any of the code paths that use these hash functions are called this error occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants