@@ -65,8 +65,6 @@ const { webidl } = require('./webidl')
65
65
const { STATUS_CODES } = require ( 'node:http' )
66
66
const GET_OR_HEAD = [ 'GET' , 'HEAD' ]
67
67
68
- const noop = ( ) => { }
69
-
70
68
const defaultUserAgent = typeof __UNDICI_IS_NODE__ !== 'undefined' || typeof esbuildDetection !== 'undefined'
71
69
? 'node'
72
70
: 'undici'
@@ -2145,23 +2143,35 @@ async function httpNetworkFetch (
2145
2143
finishFlush : zlib . constants . Z_SYNC_FLUSH
2146
2144
} ) )
2147
2145
} else if ( coding === 'deflate' ) {
2148
- decoders . push ( createInflate ( ) )
2146
+ decoders . push ( createInflate ( {
2147
+ flush : zlib . constants . Z_SYNC_FLUSH ,
2148
+ finishFlush : zlib . constants . Z_SYNC_FLUSH
2149
+ } ) )
2149
2150
} else if ( coding === 'br' ) {
2150
- decoders . push ( zlib . createBrotliDecompress ( ) )
2151
+ decoders . push ( zlib . createBrotliDecompress ( {
2152
+ flush : zlib . constants . BROTLI_OPERATION_FLUSH ,
2153
+ finishFlush : zlib . constants . BROTLI_OPERATION_FLUSH
2154
+ } ) )
2151
2155
} else {
2152
2156
decoders . length = 0
2153
2157
break
2154
2158
}
2155
2159
}
2156
2160
}
2157
2161
2162
+ const onError = this . onError . bind ( this )
2163
+
2158
2164
resolve ( {
2159
2165
status,
2160
2166
statusText,
2161
2167
headersList,
2162
2168
body : decoders . length
2163
- ? pipeline ( this . body , ...decoders , noop )
2164
- : this . body . on ( 'error' , noop )
2169
+ ? pipeline ( this . body , ...decoders , ( err ) => {
2170
+ if ( err ) {
2171
+ this . onError ( err )
2172
+ }
2173
+ } ) . on ( 'error' , onError )
2174
+ : this . body . on ( 'error' , onError )
2165
2175
} )
2166
2176
2167
2177
return true
0 commit comments