@@ -99,9 +99,6 @@ function ReadableState(options, stream, isDuplex) {
99
99
this . endEmitted = false ;
100
100
this . reading = false ;
101
101
102
- // Flipped if an 'error' is emitted.
103
- this . errorEmitted = false ;
104
-
105
102
// a flag to be able to tell if the event 'readable'/'data' is emitted
106
103
// immediately, or on a later tick. We set this to true at first, because
107
104
// any actions that shouldn't happen until "later" should generally also
@@ -1072,23 +1069,20 @@ function fromList(n, state) {
1072
1069
function endReadable ( stream ) {
1073
1070
var state = stream . _readableState ;
1074
1071
1075
- debug ( 'endReadable' , state . endEmitted , state . errorEmitted ) ;
1076
- if ( ! state . endEmitted && ! state . errorEmitted ) {
1072
+ debug ( 'endReadable' , state . endEmitted ) ;
1073
+ if ( ! state . endEmitted ) {
1077
1074
state . ended = true ;
1078
1075
process . nextTick ( endReadableNT , state , stream ) ;
1079
1076
}
1080
1077
}
1081
1078
1082
1079
function endReadableNT ( state , stream ) {
1083
- debug ( 'endReadableNT' , state . endEmitted , state . length , state . errorEmitted ) ;
1080
+ debug ( 'endReadableNT' , state . endEmitted , state . length ) ;
1084
1081
1085
1082
// Check that we didn't get one last unshift.
1086
1083
if ( ! state . endEmitted && state . length === 0 ) {
1084
+ state . endEmitted = true ;
1087
1085
stream . readable = false ;
1088
-
1089
- if ( ! state . errorEmitted ) {
1090
- state . endEmitted = true ;
1091
- stream . emit ( 'end' ) ;
1092
- }
1086
+ stream . emit ( 'end' ) ;
1093
1087
}
1094
1088
}
0 commit comments