@@ -205,7 +205,9 @@ describe('compression()', function () {
205205 client = res
206206 assert . strictEqual ( res . headers [ 'content-encoding' ] , 'gzip' )
207207 res . pause ( )
208- res . on ( 'end' , cb )
208+ res . on ( 'end' , function ( ) {
209+ server . close ( cb )
210+ } )
209211 pressure ( )
210212 } )
211213 . end ( )
@@ -258,7 +260,9 @@ describe('compression()', function () {
258260 client = res
259261 shouldNotHaveHeader ( 'Content-Encoding' ) ( res )
260262 res . pause ( )
261- res . on ( 'end' , cb )
263+ res . on ( 'end' , function ( ) {
264+ server . close ( cb )
265+ } )
262266 pressure ( )
263267 } )
264268 . end ( )
@@ -594,7 +598,10 @@ describe('compression()', function () {
594598 . get ( '/' )
595599 . set ( 'Accept-Encoding' , 'gzip' )
596600 . request ( )
597- . on ( 'response' , unchunk ( 'gzip' , onchunk , done ) )
601+ . on ( 'response' , unchunk ( 'gzip' , onchunk , function ( err ) {
602+ if ( err ) return done ( err )
603+ server . close ( done )
604+ } ) )
598605 . end ( )
599606 } )
600607
@@ -617,7 +624,10 @@ describe('compression()', function () {
617624 . get ( '/' )
618625 . set ( 'Accept-Encoding' , 'gzip' )
619626 . request ( )
620- . on ( 'response' , unchunk ( 'gzip' , onchunk , done ) )
627+ . on ( 'response' , unchunk ( 'gzip' , onchunk , function ( err ) {
628+ if ( err ) return done ( err )
629+ server . close ( done )
630+ } ) )
621631 . end ( )
622632 } )
623633
@@ -640,7 +650,10 @@ describe('compression()', function () {
640650 . get ( '/' )
641651 . set ( 'Accept-Encoding' , 'deflate' )
642652 . request ( )
643- . on ( 'response' , unchunk ( 'deflate' , onchunk , done ) )
653+ . on ( 'response' , unchunk ( 'deflate' , onchunk , function ( err ) {
654+ if ( err ) return done ( err )
655+ server . close ( done )
656+ } ) )
644657 . end ( )
645658 } )
646659 } )
0 commit comments