Skip to content

Commit

Permalink
Maybe fix v20 (#2252)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina authored Sep 8, 2023
1 parent b95f3e1 commit ea4f257
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/utils/redirecting-servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

const { createServer } = require('http')

function close (server) {
return function () {
return new Promise(resolve => {
if (typeof server.closeAllConnections === 'function') {
server.closeAllConnections()
}
server.close(resolve)
})
}
}

function startServer (t, handler) {
return new Promise(resolve => {
const server = createServer(handler)
Expand All @@ -10,7 +21,7 @@ function startServer (t, handler) {
resolve(`localhost:${server.address().port}`)
})

t.teardown(server.close.bind(server))
t.teardown(close(server))
})
}

Expand Down

0 comments on commit ea4f257

Please sign in to comment.