Skip to content

Commit

Permalink
fix: flaky leak test (#2070)
Browse files Browse the repository at this point in the history
* fix: flaky leak test

* fixuP

* fixup
  • Loading branch information
ronag committed Apr 14, 2023
1 parent 3e91915 commit 97154f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/client-keep-alive.js
Expand Up @@ -142,7 +142,7 @@ test('keep-alive header no postfix', (t) => {
body.on('end', () => {
const timeout = setTimeout(() => {
t.fail()
}, 3e3)
}, 4e3)
client.on('disconnect', () => {
t.pass()
clearTimeout(timeout)
Expand Down
4 changes: 2 additions & 2 deletions test/connect-timeout.js
Expand Up @@ -16,8 +16,8 @@ test('priotorise socket errors over timeouts', (t) => {
t.equal(err.code, 'ENOTFOUND')
})

// block for 1001ms which is enough for the dns lookup to complete and TO to fire
sleep(connectTimeout + 1)
// block for 2s which is enough for the dns lookup to complete and TO to fire
sleep(connectTimeout * 2)
})

// never connect
Expand Down
3 changes: 2 additions & 1 deletion test/fetch/fetch-leak.js
Expand Up @@ -22,6 +22,7 @@ test('do not leak', (t) => {
const controller = new AbortController()
fetch(url, { signal: controller.signal })
.then(res => res.arrayBuffer())
.catch(() => {})
.then(attack)
})

Expand All @@ -33,7 +34,7 @@ test('do not leak', (t) => {
const next = process.memoryUsage().heapUsed
if (next <= prev) {
t.pass()
} else if (count++ > 10) {
} else if (count++ > 20) {
t.fail()
} else {
prev = next
Expand Down

0 comments on commit 97154f5

Please sign in to comment.