rynop / dynamodb-local

A wrapper for AWS DynamoDB Local, intended for use in testcases
MIT License
52 stars 30 forks source link

Process exit listeners are leaking #27

Open qtiki opened 5 years ago

qtiki commented 5 years ago

Process exit listeners aren't removed properly when the child process exits. This leads to a node warning once you start and stop the offline DynamoDB more than 10 times:

(node:9960) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit

The listener seems to be registered here: https://github.com/rynop/dynamodb-local/blob/355365e1d4ba6bcad0948dd57c1d0819270794f4/index.js#L84

qtiki commented 5 years ago

Here's code to reproduce:

const db = require('dynamodb-local');

async function test() {
    for (let i = 0; i < 11; i++) {
        await db.launch(8000, null, ['-inMemory'], true);
        db.stop(8000);
    }
}

test();