Skip to content

Commit

Permalink
index: turn off watchForUpdates, due to warning:
Browse files Browse the repository at this point in the history
(node:52697) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 change listeners added to [StatWatcher]. Use emitter.setMaxListeners() to increase limit

- pin dependency versions
- use correct assert syntax
  • Loading branch information
msimerson committed Apr 2, 2024
1 parent aaf0c86 commit 6bc0f1a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -88,8 +88,8 @@ exports.load_dbs = async function () {
}

this[`${db}Lookup`] = await this.maxmind.open(dbPath, {
// this causes tests to hang, which is why mocha runs with --exit
watchForUpdates: true,
// watchForUpdates causes tests to hang unless mocha runs with --exit
watchForUpdates: false,
cache: {
max: 1000, // max items in cache
maxAge: 1000 * 60 * 60 // life time in milliseconds
Expand Down
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -10,7 +10,7 @@
"node": ">=14"
},
"scripts": {
"test": "npx mocha --exit",
"test": "npx mocha",
"lint": "npx eslint index.js test/*.js",
"lintfix": "npx eslint --fix index.js test/*.js",
"cover": "NODE_ENV=cov npx nyc --reporter=lcovonly npm run test",
Expand All @@ -34,13 +34,13 @@
},
"homepage": "https://github.com/haraka/haraka-plugin-geoip#readme",
"devDependencies": {
"eslint": ">=8",
"eslint-plugin-haraka": "*",
"haraka-test-fixtures": "*",
"mocha": "*"
"eslint": "^8.57.0",
"eslint-plugin-haraka": "^1.0.15",
"haraka-test-fixtures": "^1.3.3",
"mocha": "^10.4.0"
},
"dependencies": {
"maxmind": "^4.3.8",
"haraka-net-utils": "*"
"maxmind": "^4.3.18",
"haraka-net-utils": "^1.5.4"
}
}
12 changes: 5 additions & 7 deletions test/geoip.js
Expand Up @@ -159,19 +159,17 @@ describe('haversine', function () {
})

describe('received_headers', function () {
beforeEach(function (done) {
beforeEach(async function () {
this.plugin = new fixtures.plugin('geoip')
this.plugin.register().then(() => {
this.connection = fixtures.connection.createConnection()
this.connection.transaction = fixtures.transaction.createTransaction()
done()
})
await this.plugin.register()
this.connection = fixtures.connection.createConnection()
this.connection.transaction = fixtures.transaction.createTransaction()
})

it('generates results for each received header', function () {
this.connection.transaction.header.add_end('Received', 'from [199.176.179.3]')
this.connection.transaction.header.add_end('Received', 'from [192.48.85.146]')
const results = this.plugin.received_headers(this.connection)
assert.equal(2, results.length)
assert.equal(results.length, 2)
})
})

0 comments on commit 6bc0f1a

Please sign in to comment.