File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ const { Readable, Writable } = require ( 'stream' ) ;
4+
5+ // Tests that calling .unpipe() un-blocks a stream that is paused because
6+ // it is waiting on the writable side to finish a write().
7+
8+ const rs = new Readable ( {
9+ highWaterMark : 1 ,
10+ // That this gets called at least 20 times is the real test here.
11+ read : common . mustCallAtLeast ( ( ) => rs . push ( 'foo' ) , 20 )
12+ } ) ;
13+
14+ const ws = new Writable ( {
15+ highWaterMark : 1 ,
16+ write : common . mustCall ( ( ) => {
17+ // Ignore the callback, this write() simply never finishes.
18+ setImmediate ( ( ) => rs . unpipe ( ws ) ) ;
19+ } )
20+ } ) ;
21+
22+ let chunks = 0 ;
23+ rs . on ( 'data' , common . mustCallAtLeast ( ( ) => {
24+ chunks ++ ;
25+ if ( chunks >= 20 )
26+ rs . pause ( ) ; // Finish this test.
27+ } ) ) ;
28+
29+ rs . pipe ( ws ) ;
You can’t perform that action at this time.
0 commit comments