@@ -178,7 +178,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
178
178
}
179
179
}
180
180
181
- res . end ( ) ;
181
+ try { res . end ( ) }
182
+ catch ( ex ) { console . error ( "res.end error: %s" , ex . message ) }
182
183
}
183
184
184
185
//
@@ -209,7 +210,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
209
210
210
211
// If `response.statusCode === 304`: No 'data' event and no 'end'
211
212
if ( response . statusCode === 304 ) {
212
- return res . end ( ) ;
213
+ try { res . end ( ) }
214
+ catch ( ex ) { console . error ( "res.end error: %s" , ex . message ) }
215
+ return ;
213
216
}
214
217
215
218
//
@@ -223,9 +226,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
223
226
try {
224
227
res . write ( chunk ) ;
225
228
}
226
- catch ( er ) {
229
+ catch ( ex ) {
230
+ console . error ( "res.write error: %s" , ex . message ) ;
227
231
try { res . end ( ) }
228
- catch ( er ) { }
232
+ catch ( ex ) { console . error ( "res.write error: %s" , ex . message ) }
229
233
}
230
234
}
231
235
} ) ;
@@ -240,8 +244,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
240
244
response . on ( 'end' , function ( ) {
241
245
if ( ! errState ) {
242
246
reverseProxy . removeListener ( 'error' , proxyError ) ;
243
- res . end ( ) ;
244
-
247
+
248
+ try { res . end ( ) }
249
+ catch ( ex ) { console . error ( "res.end error: %s" , ex . message ) }
250
+
245
251
// Emit the `end` event now that we have completed proxying
246
252
self . emit ( 'end' , req , res ) ;
247
253
}
0 commit comments