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

Requiring Mongoose creates open handles #7360

Closed
craigfay opened this issue Nov 12, 2018 · 4 comments
Closed

Requiring Mongoose creates open handles #7360

craigfay opened this issue Nov 12, 2018 · 4 comments
Labels

Comments

@craigfay
Copy link

🐛 Bug Report

Although similar mongoose integration issues exist in this tracker, most deal primarily with failure to close mongoose connections properly. I believe this issue is unique, in that it is caused by simply requiring mongoose in a test.

Importing Mongoose as a dependency (or any JS module that depends on Mongoose) causes the following message when Jest is run with --detectOpenHandles:

> jest int --detectOpenHandles

 PASS  ./main.int.test.js
  ✓ true is true (6ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.524s, estimated 2s
Ran all test suites matching /int/i.

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

  ●  DNSCHANNEL

      at dns.js:338:23

To Reproduce

/**
 * Dependencies
 */
const mongoose = require('mongoose');

test('true is true', () => {
    expect(true).toBe(true);
})
  "dependencies": {
    "mongoose": "^5.3.11"
  },
  "devDependencies": {
    "jest": "^23.5.0"
  },
  "jest": {
    "moduleNameMapper": {
      "testEnvironment": "node"
    },
    "moduleDirectories": [
      "node_modules"
    ]
  }

Expected behavior

The test should be able to include modules that use mongoose as a dependency and terminate properly.

Link to Repo

https://github.com/CBFay/jest-mongoose-open-handle

Run npx envinfo --preset jest

Paste the results here:

System:
    OS: macOS Sierra 10.12.6
    CPU: (4) x64 Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz
  Binaries:
    Node: 10.5.0 - /usr/local/bin/node
    npm: 6.1.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^23.5.0 => 23.6.0 
@kevinburke
Copy link

Previously here: #6423

Perhaps the answer you are looking for may be found there.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants