Skip to content

Commit 3e74b11

Browse files
committed
fix: require latest Bottleneck to avoid memory leak when creating many instances
1 parent f9c00b0 commit 3e74b11

File tree

8 files changed

+82
-23
lines changed

8 files changed

+82
-23
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ jobs:
1313
- stage: test
1414
node_js: 8
1515
- node_js: 10
16-
- node_js: lts/*
16+
env: Node 10 & coverage upload
1717
after_script:
1818
- npm run coverage:upload
19+
- node_js: lts/*
20+
env: memory-test
21+
script: npm run test:memory
1922
- stage: release
2023
env: semantic-release
2124
node_js: lts/*
@@ -30,8 +33,6 @@ jobs:
3033
- node scripts/generate-routes
3134
# commit changes and push back to branch on GitHub. If there are no changes then exit without error
3235
- 'git commit -a -m "build: routes" --author="Octokit Bot <[email protected]>" && git push "https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG" ${TRAVIS_BRANCH} || true'
33-
allow_failures:
34-
3536

3637
stages:
3738
- test

package-lock.json

Lines changed: 58 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"coverage": "nyc report --reporter=html && open coverage/index.html",
1212
"coverage:upload": "nyc report --reporter=text-lcov | coveralls",
1313
"pretest": "standard",
14-
"test": "nyc mocha test/"
14+
"test": "nyc mocha test/integration/",
15+
"test:memory": "node test/memory-leakage-test"
1516
},
1617
"repository": {
1718
"type": "git",
@@ -35,14 +36,15 @@
3536
]
3637
},
3738
"dependencies": {
38-
"bottleneck": "^2.15.0"
39+
"bottleneck": "^2.15.3"
3940
},
4041
"devDependencies": {
4142
"@octokit/request": "2.2.1",
4243
"@octokit/rest": "^16.3.0",
4344
"@octokit/routes": "18.1.2",
4445
"chai": "^4.2.0",
4546
"coveralls": "^3.0.2",
47+
"leakage": "^0.4.0",
4648
"mocha": "^5.2.0",
4749
"nyc": "^13.1.0",
4850
"semantic-release": "^15.13.1",
File renamed without changes.

test/index.js renamed to test/integration/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ describe('Github API best practices', function () {
156156
})
157157

158158
it('Should match custom routes when checking notification triggers', function () {
159-
const plugin = require('../lib')
159+
const plugin = require('../../lib')
160160

161161
expect(plugin.triggersNotification('/abc/def')).to.equal(false)
162162
expect(plugin.triggersNotification('/orgs/abc/invitation')).to.equal(false)

test/octokit.js renamed to test/integration/octokit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const Octokit = require('@octokit/rest')
22
const HttpError = require('@octokit/request/lib/http-error')
3-
const throttlingPlugin = require('..')
3+
const throttlingPlugin = require('../..')
44

55
module.exports = Octokit
66
.plugin((octokit) => {
File renamed without changes.

test/memory-leakage-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { iterate } = require('leakage')
2+
const Octokit = require('@octokit/rest')
3+
.plugin(require('..'))
4+
5+
const result = iterate(() => {
6+
Octokit({
7+
throttle: {
8+
onAbuseLimit: () => {},
9+
onRateLimit: () => {}
10+
}
11+
})
12+
})
13+
14+
result.printSummary()

0 commit comments

Comments
 (0)