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

NodeAdapter Memory Leaks indicated with jest --detectLeaks #474

Open
antho1jp opened this issue Nov 21, 2022 · 0 comments
Open

NodeAdapter Memory Leaks indicated with jest --detectLeaks #474

antho1jp opened this issue Nov 21, 2022 · 0 comments

Comments

@antho1jp
Copy link

Description

This appears to be similar if not the same issue as 370.

Shareable Source

describe("Simple Example", function () {
  it("fetches a post", async function () {
    const polly = new Polly("Simple Example", {
      adapters: [NodeAdapter], // Hook into `fetch`
      persister: "fs",
      logLevel: "info", // Log requests to console
      mode: MODES.RECORD,
    });
    const response = await fetch(
      "https://jsonplaceholder.typicode.com/posts/1"
    );
    const post: PostData = (await response.json()) as PostData;
    expect(response.status).toBe(200);
    expect(post.id).toBe(1);
    await polly.stop();
  });
});

Error Message & Stack Trace

 FAIL  tests/pollyjs.test.ts
  ● Test suite failed to run

    EXPERIMENTAL FEATURE!
    Your test suite is leaking memory. Please ensure all references are cleaned.

    There is a number of things that can leak memory:
      - Async operations that have not finished (e.g. fs.readFile).
      - Timers not properly mocked (e.g. setInterval, setTimeout).
      - Keeping references to the global scope.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:150:18)
      at node_modules/@jest/core/build/TestScheduler.js:254:19
      at node_modules/emittery/index.js:363:13
          at Array.map (<anonymous>)
      at Emittery.emit (node_modules/emittery/index.js:361:23)

Config

Copy the config used to setup the Polly instance:

const polly = new Polly("Simple Example", {
      adapters: [NodeAdapter], // Hook into `fetch`
      persister: "fs",
      logLevel: "info", // Log requests to console
      mode: MODES.RECORD,
    });

Dependencies

Copy the @pollyjs dependencies from package.json:

"devDependencies": {
    "@pollyjs/adapter-node-http": "^6.0.5",
    "@pollyjs/core": "^6.0.5",
    "@pollyjs/persister-fs": "^6.0.5",
  }

Relevant Links

minimal reproduction

Environment

Node.js v16.15.1
npm v8.11.0
darwin 22.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant