(stream, err, sync)
| 202 | } |
| 203 | |
| 204 | function errorOrDestroy(stream, err, sync) { |
| 205 | // We have tests that rely on errors being emitted |
| 206 | // in the same tick, so changing this is semver major. |
| 207 | // For now when you opt-in to autoDestroy we allow |
| 208 | // the error to be emitted nextTick. In a future |
| 209 | // semver major update we should change the default to this. |
| 210 | |
| 211 | const r = stream._readableState; |
| 212 | const w = stream._writableState; |
| 213 | |
| 214 | if ( |
| 215 | (w && (w[kState] ? (w[kState] & kDestroyed) !== 0 : w.destroyed)) || |
| 216 | (r && (r[kState] ? (r[kState] & kDestroyed) !== 0 : r.destroyed)) |
| 217 | ) { |
| 218 | return this; |
| 219 | } |
| 220 | |
| 221 | if ( |
| 222 | (r && (r[kState] & kAutoDestroy) !== 0) || |
| 223 | (w && (w[kState] & kAutoDestroy) !== 0) |
| 224 | ) { |
| 225 | stream.destroy(err); |
| 226 | } else if (err) { |
| 227 | // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364 |
| 228 | err.stack; // eslint-disable-line no-unused-expressions |
| 229 | |
| 230 | if (w && (w[kState] & kErrored) === 0) { |
| 231 | w.errored = err; |
| 232 | } |
| 233 | if (r && (r[kState] & kErrored) === 0) { |
| 234 | r.errored = err; |
| 235 | } |
| 236 | if (sync) { |
| 237 | process.nextTick(emitErrorNT, stream, err); |
| 238 | } else { |
| 239 | emitErrorNT(stream, err); |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | function construct(stream, cb) { |
| 245 | if (typeof stream._construct !== 'function') { |
no test coverage detected
searching dependent graphs…