question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak in knex v0.13.0

See original GitHub issue

Hi,

When importing, then destroying, then reset modules a lot of times with jest, I have some warning about memory leak MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGABRT listeners added. Use emitter.setMaxListeners() to increase limit

I think that destroy() leave listener that should be removed.

Here is the (useless) code to reproduce the issue :

//@flow

import k from 'knex';
import path from 'path';

const config = {
  client: 'sqlite3',
  connection: {
    filename: path.join(__dirname, './database.sqlite'),
  },
  pool: {
    min: 1,
    max: 1,
  },
  migrations: {
    tableName: 'knex_migrations',
  },
  useNullAsDefault: true,
  timezone: 'UTC',
};

let knex;

describe('pppppppppp', () => {
  beforeEach(async () => {
    jest.resetModules();
    knex = k(config);
  });

  afterEach(async () => {
    await knex.destroy();
  });

  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
  test('test', () => {});
});

the output :

Is it a bad use or a bug ? Thanks in advance.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
badwulfycommented, Jul 27, 2017

@fl0w nop, it does not fix the issue

0reactions
wubzzcommented, Nov 1, 2017

From my previous tests this should be fixed by #2208, so closing this for now. If it’s still an issue in upcoming 0.14, feel free to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Knex.js: JavaScript heap out of memory
I'm working on a project which uses knex.js for database migration. I tried to query the data ...
Read more >
node-memwatch | Yarn - Package Manager
node-memwatch is here to help you detect and find memory leaks in Node.JS code. It provides: A leak event, emitted when it appears...
Read more >
Developers - Memory leak when using transactions -
Using knex transactions in tests causes a memory leak. Likely also in production. Detectable in jest tests using their --detectLeaks ...
Read more >
Debugging Memory Leaks in Node.js Applications
js application using restify and put a little source of memory leak within it. All experiments here are made with Node.js v0.12.7, which...
Read more >
Understanding Memory Leaks in Nodejs | by Chidume Nnamdi
... and allocating memory without knowing it. How we manage them can make or mar our software. In our effort to understand what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found