Closed hekike closed 6 years ago
Great catch @hekike!
To give a bit more details: it seems the regression was introduced by https://github.com/nodejs/node/commit/cf5f9867ff3e700dfd72519e7bdeb701e254317f, which effectively makes adding a 'readable'
listener stay in non-flowing mode even after a 'data'
event listener is added to the same stream.
That change was released with Node.js v10.0.0. Before that change, adding a 'data'
event listener to a stream would always make it "flow". It's a bit unfortunate that it doesn't seem to be listed anywhere in the list of backward incompatible changes.
Long term, ideally we would not mix both streaming modes if possible, and we would use read()
instead of .on('data'
. but that would potentially be a bit involved, and so for the near term your fix looks good to me.
It's a bit unfortunate that it doesn't seem to be listed anywhere in the list of backward incompatible changes.
My apologies, it is listed, since all major changes are listed in the changelog (look for SEMVER-MAJOR
and readable
).
Turn res stream readable immediately to make it possible to consume later in inherited clients.