Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Apr 28, 2024
1 parent f804789 commit 3cee000
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/issue-3131.js
@@ -0,0 +1,43 @@
'use strict'

const { createServer } = require('node:http')
const { EventEmitter, once } = require('node:events')
const { request } = require('../')
const { test } = require('node:test')
const { closeServerAsPromise } = require('./utils/node-http')
const { strictEqual } = require('node:assert')

test('issue #3131', async (t) => {
const emitter = new EventEmitter()

const server = createServer((req, res) => {
res.end('Hi')
})

server.listen(0)

await once(server, 'listening')

t.after(closeServerAsPromise(server))

const url = `http://localhost:${server.address().port}`

let warningEmitted = false
function onWarning () {
warningEmitted = true
}
process.on('warning', onWarning)
t.after(() => {
process.off('warning', onWarning)
})

const promises = new Array(50)

for (let i = 0; i < promises.length; ++i) {
promises[i] = request(url, { signal: emitter })
}

await Promise.all(promises)

strictEqual(warningEmitted, false)
})

0 comments on commit 3cee000

Please sign in to comment.