Skip to content

Commit 933b383

Browse files
authored
Use isHttp2 check to detect we are canceling an HTTP2 request (#433)
1 parent 14a75de commit 933b383

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ const fastifyReplyFrom = fp(function from (fastify, opts, next) {
4747
globalAgent: opts.globalAgent,
4848
destroyAgent: opts.destroyAgent
4949
})
50+
51+
const isHttp2 = !!opts.http2
5052
if (requestBuilt instanceof Error) {
5153
next(requestBuilt)
5254
return
@@ -209,7 +211,7 @@ const fastifyReplyFrom = fp(function from (fastify, opts, next) {
209211
onError(this, { error: new BadGatewayError() })
210212
this.request.log.warn(err, 'response has invalid status code')
211213
}
212-
if (this.request.raw.aborted && res.stream) {
214+
if (this.request.raw.aborted && isHttp2) {
213215
// the request could have been canceled before we got a response from the target
214216
// forward this to the upstream server and close the stream to prevent leaks
215217
res.stream.close(NGHTTP2_CANCEL)

0 commit comments

Comments
 (0)