| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dd72df0 commit 29b1966
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1233,6 +1233,9 @@ function nReadingNextTick(self) { | |||
| 1233 | 1233 | // If the user uses them, then switch into old mode. | |
| 1234 | 1234 | Readable.prototype.resume = function() { | |
| 1235 | 1235 | const state = this._readableState; | |
| 1236 | + if ((state[kState] & kDestroyed) !== 0) { | ||
| 1237 | + return this; | ||
| 1238 | + } | ||
| 1236 | 1239 | if ((state[kState] & kFlowing) === 0) { | |
| 1237 | 1240 | debug('resume'); | |
| 1238 | 1241 | // We flow only if there is no one listening | |
@@ -1273,6 +1276,9 @@ function resume_(stream, state) { | |||
| 1273 | 1276 | ||
| 1274 | 1277 | Readable.prototype.pause = function() { | |
| 1275 | 1278 | const state = this._readableState; | |
| 1279 | + if ((state[kState] & kDestroyed) !== 0) { | ||
| 1280 | + return this; | ||
| 1281 | + } | ||
| 1276 | 1282 | debug('call pause'); | |
| 1277 | 1283 | if ((state[kState] & (kHasFlowing | kFlowing)) !== kHasFlowing) { | |
| 1278 | 1284 | debug('pause'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -118,3 +118,13 @@ const http = require('http'); | |||
| 118 | 118 | req.end('asd'); | |
| 119 | 119 | })); | |
| 120 | 120 | } | |
| 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments