nodejs / readable-stream

Node-core streams for userland
https://nodejs.org/api/stream.html
Other
1.03k stars 227 forks source link

Don't assign to readonly `promises` property when `READABLE_STREAM === 'disable'` #457

Closed trxcllnt closed 2 years ago

trxcllnt commented 3 years ago

Follow-up to https://github.com/nodejs/readable-stream/pull/399. This PR fixes the below error, caused by recent versions of node adding a readonly promises property to the Stream constructor.

$ READABLE_STREAM=disable node
Welcome to Node.js v15.14.0.
Type ".help" for more information.
> var Readable = require('.')
Uncaught TypeError: Cannot set property promises of function Stream(opts) {
  EE.call(this, opts);
} which has only a getter
    at Function.assign (<anonymous>)
    at Object.<anonymous> (/home/ptaylor/dev/readable-stream/readable.js:4:10)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
> 
trxcllnt commented 3 years ago

cc @mcollina because you helped review #399.