File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -1238,6 +1238,9 @@ function nReadingNextTick(self) {
12381238// If the user uses them, then switch into old mode.
12391239Readable . prototype . resume = function ( ) {
12401240 const state = this . _readableState ;
1241+ if ( ( state [ kState ] & kDestroyed ) !== 0 ) {
1242+ return this ;
1243+ }
12411244 if ( ( state [ kState ] & kFlowing ) === 0 ) {
12421245 debug ( 'resume' ) ;
12431246 // We flow only if there is no one listening
@@ -1278,6 +1281,9 @@ function resume_(stream, state) {
12781281
12791282Readable . prototype . pause = function ( ) {
12801283 const state = this . _readableState ;
1284+ if ( ( state [ kState ] & kDestroyed ) !== 0 ) {
1285+ return this ;
1286+ }
12811287 debug ( 'call pause' ) ;
12821288 if ( ( state [ kState ] & ( kHasFlowing | kFlowing ) ) !== kHasFlowing ) {
12831289 debug ( 'pause' ) ;
Original file line number Diff line number Diff line change @@ -118,3 +118,13 @@ const http = require('http');
118118 req . end ( 'asd' ) ;
119119 } ) ) ;
120120}
121+
122+ {
123+ // resume() and pause() should be no-ops on destroyed streams.
124+ const r = new Readable ( { read ( ) { } } ) ;
125+ r . destroy ( ) ;
126+ r . on ( 'resume' , common . mustNotCall ( ) ) ;
127+ r . on ( 'pause' , common . mustNotCall ( ) ) ;
128+ r . resume ( ) ;
129+ r . pause ( ) ;
130+ }
You can’t perform that action at this time.
0 commit comments