File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ class ChartjsNode {
9696 chunkSize : 2048 // in bytes.
9797 } ) ;
9898 readableStream . put ( buffer ) ;
99+ readableStream . stop ( ) ;
99100 return {
100101 stream : readableStream ,
101102 length : buffer . length
Original file line number Diff line number Diff line change @@ -104,7 +104,22 @@ describe('chartjs', function () {
104104 } )
105105 . then ( imageStream => {
106106 assert ( imageStream . stream instanceof stream . Readable ) ;
107- debug ( 'Sucessfully wrote image to a Readable stream' ) ;
107+ var length = imageStream . length ;
108+ var readLength = 0 ;
109+ return new Promise ( ( resolve , reject ) => {
110+ imageStream . stream . on ( 'data' , d => {
111+ readLength += d . length ;
112+ if ( readLength === length ) {
113+ debug ( 'Sucessfully wrote image to a Readable stream' ) ;
114+ resolve ( ) ;
115+ }
116+ } ) ;
117+ setTimeout ( ( ) => {
118+ debug ( 'length: ' + length ) ;
119+ debug ( 'readLength: ' + readLength ) ;
120+ reject ( 'Failed to read complete chart image stream in time' ) ;
121+ } , 1000 ) ;
122+ } ) ;
108123 } ) ;
109124 } ) ;
110125 it ( 'should return the image as data url' , function ( ) {
You can’t perform that action at this time.
0 commit comments