summaryrefslogtreecommitdiff
path: root/test/parallel/test-stream-pipeline.js
Commit message (Collapse)AuthorAgeFilesLines
* stream: unify stream utilsRobert Nagy2021-07-111-1/+1
| | | | | | | | | Unify stream helps into utils. PR-URL: https://github.com/nodejs/node/pull/39294 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* stream: use finished for pumpRobert Nagy2021-07-021-33/+0
| | | | | | | | | Re-use existing compat logic for pump by using finished. PR-URL: https://github.com/nodejs/node/pull/39203 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
* stream: fix pipeline pumpRobert Nagy2021-06-141-0/+33
| | | | | | | | Refs: https://github.com/nodejs/node/issues/39005 PR-URL: https://github.com/nodejs/node/pull/39006 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* test: prepare for consistent comma-dangle lint ruleRich Trott2021-04-011-2/+2
| | | | | | | | | Make changes so that tests will pass when the comma-dangle settings applied to the rest of the code base are also applied to tests. PR-URL: https://github.com/nodejs/node/pull/37930 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
* Revert "http: align with stream.Writable"Matteo Collina2021-03-311-0/+34
| | | | | | | | | | | | | | | This reverts commit e2f5bb7574e7e8189a3e38fc4d00c1213fd7160f. Reverted as it caused a significant performance regression. See: https://github.com/nodejs/node/issues/37937 PR-URL: https://github.com/nodejs/node/pull/37963 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* stream: pipeline accept Buffer as a valid first argumentNitzan Uziely2021-03-221-0/+16
| | | | | | | | | | | | | | | change isStream to also check existence of on, so it wont mistake buffers as Streams. fixes: https://github.com/nodejs/node/issues/37731 PR-URL: https://github.com/nodejs/node/pull/37739 Fixes: https://github.com/nodejs/node/issues/37731 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* test: refactor code to use AbortSignal.abort()Wassim Chegham2021-03-201-3/+1
| | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/37798 Refs: https://github.com/whatwg/dom/pull/960 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com>
* http: align with stream.WritableRobert Nagy2021-03-101-34/+0
| | | | | | | | | | | | Futher aligns OutgoingMessage with stream.Writable. In particular re-uses the construct/destroy logic from streams. Due to a lot of subtle assumptions this PR unfortunately touches a lot of different parts. PR-URL: https://github.com/nodejs/node/pull/36816 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
* stream: add AbortSignal to promisified pipelineNitzan Uziely2021-02-181-0/+72
| | | | | | | | | | | add support for AbortSignal to promisified pipeline. Resolves: https://github.com/nodejs/node/issues/37321 PR-URL: https://github.com/nodejs/node/pull/37359 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
* stream: accept iterable as a valid first argumentZiJian Liu2020-12-151-0/+16
| | | | | | | | | | | Fixes: https://github.com/nodejs/node/issues/36437 PR-URL: https://github.com/nodejs/node/pull/36479 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
* tools: enable no-unused-expressions lint ruleMichaël Zasso2020-12-071-8/+2
| | | | | | | | | | | | | Fixes: https://github.com/nodejs/node/issues/36246 PR-URL: https://github.com/nodejs/node/pull/36248 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* stream: support abort signalBenjamin Gruenbaum2020-12-071-1/+31
| | | | | | PR-URL: https://github.com/nodejs/node/pull/36061 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
* stream: remove isPromise utility functionAntoine du Hamel2020-11-091-0/+21
| | | | | | | | | | | | The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once. PR-URL: https://github.com/nodejs/node/pull/35925 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* test: add common.mustSucceedTobias Nießen2020-10-171-34/+19
| | | | | | PR-URL: https://github.com/nodejs/node/pull/35086 Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* stream: try to wait for flush to complete before 'finish'Robert Nagy2020-07-151-0/+24
| | | | | | | | | | | | | | | | Due to compat reasons Transform streams don't always wait for flush to complete before finishing the stream. Try to wait when possible, i.e. when the user does not override _final. Fixes: https://github.com/nodejs/node/issues/34274 PR-URL: https://github.com/nodejs/node/pull/34314 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Zeyu Yang <himself65@outlook.com>
* test: add arrayOfStreams to pipelinerickyes2020-07-071-0/+20
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/34156 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* stream: fix broken pipeline testRobert Nagy2020-04-241-1/+1
| | | | | | | | | | | | | | | | | | An unfortunate overlap between two PR that by themselves pass CI but together pass a test. https://github.com/nodejs/node/pull/32967 changes so that pipeline does not wait for 'close'. https://github.com/nodejs/node/pull/32968 changed so that all streams are not destroyed. Which made one test fail when expected the stream to be destroyed during pipeline callback. PR-URL: https://github.com/nodejs/node/pull/33030 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
* stream: pipeline should only destroy un-finished streamsRobert Nagy2020-04-231-1/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | This PR logically reverts https://github.com/nodejs/node/pull/31940 which has caused lots of unnecessary breakage in the ecosystem. This PR also aligns better with the actual documented behavior: `stream.pipeline()` will call `stream.destroy(err)` on all streams except: * `Readable` streams which have emitted `'end'` or `'close'`. * `Writable` streams which have emitted `'finish'` or `'close'`. The behavior introduced in https://github.com/nodejs/node/pull/31940 was much more aggressive in terms of destroying streams. This was good for avoiding potential resources leaks however breaks some common assumputions in legacy streams. Furthermore, it makes the code simpler and removes some hacks. Fixes: https://github.com/nodejs/node/issues/32954 Fixes: https://github.com/nodejs/node/issues/32955 PR-URL: https://github.com/nodejs/node/pull/32968 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Mathias Buus <mathiasbuus@gmail.com>
* stream: make pipeline try to wait for 'close'Robert Nagy2020-03-271-1/+42
| | | | | | | | | | | | Pipeline uses eos which will invoke the callback on 'finish' and 'end' before all streams have been fully destroyed. Fixes: https://github.com/nodejs/node/issues/32032 PR-URL: https://github.com/nodejs/node/pull/32158 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* stream: fix pipeline with dest in objectModeRobert Nagy2020-03-251-0/+12
| | | | | | | | | | | pipeline did not support destination with generator that does not return strings or buffers. PR-URL: https://github.com/nodejs/node/pull/32414 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* stream: add pipeline test for destroy of returned streamRobert Nagy2020-03-251-0/+17
| | | | | | | | | Adds a test to ensure that destroying the returned stream of pipeline will cause a premature close error. PR-URL: https://github.com/nodejs/node/pull/32425 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* stream: avoid destroying writable sourceRobert Nagy2020-03-111-0/+16
| | | | | | | | | | | | | User might still want to be able to use the writable side of src. This is in the case where e.g. the Duplex input is not directly connected to its output. Such a case could happen when the Duplex is reading from a socket and then echos the data back on the same socket. PR-URL: https://github.com/nodejs/node/pull/32198 Refs: https://github.com/nodejs/node/commit/4d93e105bfad79ff6c6f01e4b7c2fdd70caeb43b#commitcomment-37751035 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* stream: avoid destroying http1 objectsRobert Nagy2020-03-111-0/+21
| | | | | | | | | | | | | http1 objects are coupled with their corresponding res/req and cannot be treated independently as normal streams. Add a special exception for this in the pipeline cleanup. Fixes: https://github.com/nodejs/node/issues/32184 PR-URL: https://github.com/nodejs/node/pull/32197 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* stream: do not swallow errors with async iterators and pipelineMatteo Collina2020-03-111-0/+27
| | | | | | | | | | | | Before this patch, pipeline() could swallow errors by pre-emptively producing a ERR_STREAM_PREMATURE_CLOSE that was not really helpful to the user. Co-Authored-By: Robert Nagy <ronagy@icloud.com> PR-URL: https://github.com/nodejs/node/pull/32051 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
* stream: don't destroy final readable stream in pipelineRobert Nagy2020-03-081-1/+47
| | | | | | | | | | | If the last stream in a pipeline is still usable/readable don't destroy it to allow further composition. Fixes: https://github.com/nodejs/node/issues/32105 PR-URL: https://github.com/nodejs/node/pull/32110 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
* stream: fix finished w/ 'close' before 'end'Robert Nagy2020-03-031-0/+18
| | | | | | | | | Emitting 'close' before 'end' on a Readable should result in a premature close error. PR-URL: https://github.com/nodejs/node/pull/31545 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* stream: fix multiple destroy callsRobert Nagy2020-02-291-3/+1
| | | | | | | | | | | | | | | Previously destroy could be called multiple times causing inconsistent and hard to predict behavior. Furthermore, since the stream _destroy implementation can only be called once, the behavior of applying destroy multiple times becomes unclear. This changes so that only the first destroy() call is executed and any subsequent calls are noops. PR-URL: https://github.com/nodejs/node/pull/29197 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* stream: ensure pipeline always destroys streamsRobert Nagy2020-02-261-1/+14
| | | | | | | | | | | There was an edge case where an incorrect assumption was made in regardos whether eos/finished means that the stream is actually destroyed or not. PR-URL: https://github.com/nodejs/node/pull/31940 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
* stream: fix broken pipeline error propagationRobert Nagy2020-02-241-5/+1
| | | | | | | | | | If the destination was an async function any error thrown from that function would be swallowed. PR-URL: https://github.com/nodejs/node/pull/31835 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
* stream: support passing generator functions into pipeline()Robert Nagy2020-01-171-0/+397
| | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/31223 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* stream: pipeline should use req.abort() to destroy responseRobert Nagy2019-12-251-1/+34
| | | | | | | | | | | | | | | | | | | | | | destroy(err) on http response will propagate the error to the request causing 'error' to be unexpectedly emitted. Furthermore, response.destroy() unlike request.abort() does not _dump buffered data. Fixes a breaking change introduced in https://github.com/nodejs/node/commit/648088289d619bfb149fe90316ce0127083c4c99. Prefer res.req.abort() over res.destroy() until this situation is clarified. Fixes: https://github.com/nodejs/node/issues/31029 Refs: https://github.com/nodejs/node/commit/648088289d619bfb149fe90316ce0127083c4c99 PR-URL: https://github.com/nodejs/node/pull/31054 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
* stream: make all streams error in a pipelineMatteo Collina2019-12-141-0/+6
| | | | | | | | | | | | | | This changes makes all stream in a pipeline emit 'error' in case of an abnormal termination of the pipeline. If the last stream is currently being async iterated, this change will make the iteration reject accordingly. See: https://github.com/nodejs/node/pull/30861 Fixes: https://github.com/nodejs/node/issues/28194 PR-URL: https://github.com/nodejs/node/pull/30869 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* benchmark,doc,lib,test: capitalize commentsRuben Bridgewater2019-02-281-1/+1
| | | | | | | | | | This updates a lot of comments. PR-URL: https://github.com/nodejs/node/pull/26223 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
* test: split out http2 from test-stream-pipelineRich Trott2018-11-241-32/+0
| | | | | | | | | | | | | | | | Splitting out the http2 portion of the test has a few benfits: * We don't skip the rest of the tests if `node` is compiled without crypto. * We can find out if the http2 portion of the test is responsible for the timeouts reported in issue 24456. Refs: https://github.com/nodejs/node/issues/24456 PR-URL: https://github.com/nodejs/node/pull/24631 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* test,stream: fix pipeline test so it runs well on Windows in older nodesMatteo Collina2018-08-241-0/+13
| | | | | | | | | | | | | This test is ported automatically in readable-stream, and it fails there on Windows and older Node.js versions because of some bad interactions between the code and the event loop on Windows. See: https://github.com/nodejs/readable-stream/issues/353 PR-URL: https://github.com/nodejs/node/pull/22456 Reviewed-By: Mathias Buus <mathiasbuus@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
* test: make crashOnUnhandleRejection opt-outMichaël Zasso2018-07-191-2/+0
| | | | | | | | | | | | | | | | | | This commit removes `common.crashOnUnhandledRejection()` and adds `common.disableCrashOnUnhandledRejection()`. To reduce the risk of mistakes and make writing tests that involve promises simpler, always install the unhandledRejection hook in tests and provide a way to disable it for the rare cases where it's needed. PR-URL: https://github.com/nodejs/node/pull/21849 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
* stream: make the pipeline callback mandatoryRuben Bridgewater2018-06-081-14/+5
| | | | | | | | | | | | | | Right now when not adding a callback to the pipeline it could cause an uncaught exception if there is an error. Instead, just make the callback mandatory as mostly done in all other Node.js callback APIs so users explicitly have to decide what to do in such situations. PR-URL: https://github.com/nodejs/node/pull/21054 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* test: remove unref in http2 testAnatoli Papirovski2018-06-071-6/+0
| | | | | | | | The bug referenced in this TODO was fixed and this test no longer requires this code to pass. PR-URL: https://github.com/nodejs/node/pull/21145 Reviewed-By: Rich Trott <rtrott@gmail.com>
* stream: ensure Stream.pipeline re-throws errors without callbackBlaine Bublitz2018-05-311-3/+35
| | | | | | | | | | | | Fixes an issue where Stream.pipeline wouldn't re-throw errors on a stream if no callback was specified, thus swallowing said errors. Fixes: https://github.com/nodejs/node/issues/20303 PR-URL: https://github.com/nodejs/node/pull/20437 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* stream: add pipeline and finishedMathias Buus2018-04-161-0/+483
PR-URL: https://github.com/nodejs/node/pull/19828 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>