Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function buildRequest (opts) {
const isBalanced = Array.isArray(opts.base) && opts.base.length > 1
const undiciOpts = opts.undici || {}
const globalAgent = opts.globalAgent
const destroyAgent = opts.destroyAgent
const destroyAgent = opts.destroyAgent || false
let http2Client
let undiciAgent
let undiciInstance
Expand Down
22 changes: 22 additions & 0 deletions test/undici-no-destroy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,25 @@ test('destroyAgent false', async (t) => {
await instance.ready()
await instance.close()
})

test('destroyAgent default false', async (t) => {
const mockAgent = new undici.Agent()
mockAgent.destroy = () => {
t.fail()
}
const instance = Fastify()

t.after(() => instance.close())

instance.get('/', (_request, reply) => {
reply.from()
})

instance.register(From, {
base: 'http://localhost:4242',
undici: mockAgent
})

await instance.ready()
await instance.close()
})
Loading