vmpowerio/chartjs-node

Unable to stream to concat-stream

Closed this issue · 3 comments

I intend to output the stream to string using concat-stream instead of writing to file system, but it doesn't seems to work. below is the sample code:-

let concat = require('concat-stream');

...
.then(streamResult => {
    // using the length property you can do things like
    // directly upload the image to s3 by using the
    // stream and length properties
    streamResult.stream // => Stream object
    streamResult.length // => Integer length of stream
    
    let imgStr = '';
    let cs = concat(buffer => {
      imgStr = buffer.toString('base64');

      console.log(imgStr);
    });
      
    streamResult.stream.pipe(cs);
    
    // write to a file
    // return chartNode.writeImageToFile('image/png', './testimage.png');
})
.then(() => {
    // chart is now written to the file path
    // ./testimage.png
});

I am new to javascript and stream, and hope someone can give me a pointer. Thanks!

Thanks for reporting this @andrewspy looks like we aren't closing the ReadableStream we're providing you. PR #15 will fix this. I'll have a new package out shortly.

Closed via #15. published chartjs-node@1.4.0 with this fix. Cheers! 🍻

@sedouard Confirming the issue is fixed.

Thanks!