File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ const { once } = require ( 'internal/util' ) ;
34let eos ;
45
56function destroy ( err , cb ) {
@@ -11,13 +12,17 @@ function destroy(err, cb) {
1112 err = null ;
1213 }
1314
15+ if ( typeof cb === 'function' ) {
16+ // TODO(ronag): Remove once cb is invoked only through eos.
17+ cb = once ( cb ) ;
18+
19+ if ( ! eos ) eos = require ( 'internal/streams/end-of-stream' ) ;
20+ eos ( this , ( err ) => {
21+ cb ( err && err . code !== 'ERR_STREAM_PREMATURE_CLOSE' ? err : undefined ) ;
22+ } ) ;
23+ }
24+
1425 if ( ( w && w . destroyed ) || ( r && r . destroyed ) ) {
15- if ( typeof cb === 'function' ) {
16- if ( ! eos ) eos = require ( 'internal/streams/end-of-stream' ) ;
17- eos ( this , ( err ) => {
18- cb ( err && err . code !== 'ERR_STREAM_PREMATURE_CLOSE' ? err : undefined ) ;
19- } ) ;
20- }
2126 return this ;
2227 }
2328
You can’t perform that action at this time.
0 commit comments