Skip to content

Commit

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

* fixuP

* fixup
  • Loading branch information
ronag authored and crysmags committed Feb 27, 2024
1 parent 155ce78 commit 86ce0fd
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 86ce0fd

Please sign in to comment.