chore: fix net specs when rerunning locally (#22745)

This commit is contained in:
Samuel Attard 2020-03-18 16:35:23 -07:00 committed by GitHub
parent f3fd40c221
commit e58a35e5aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,8 +60,10 @@ function respondNTimes (fn: http.RequestListener, n: number): Promise<string> {
const server = http.createServer((request, response) => { const server = http.createServer((request, response) => {
fn(request, response) fn(request, response)
// don't close if a redirect was returned // don't close if a redirect was returned
n-- if ((response.statusCode < 300 || response.statusCode >= 399) && n <= 0) {
if ((response.statusCode < 300 || response.statusCode >= 399) && n <= 0) { server.close() } n--
server.close()
}
}) })
server.listen(0, '127.0.0.1', () => { server.listen(0, '127.0.0.1', () => {
resolve(`http://127.0.0.1:${(server.address() as AddressInfo).port}`) resolve(`http://127.0.0.1:${(server.address() as AddressInfo).port}`)