Skip to content

Commit

Permalink
fix(exporter-collector): remove Readable.from for node8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
alisabzevari committed Jul 8, 2021
1 parent 4c91cfb commit 62c11b4
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -83,14 +83,22 @@ export function sendWithHttp<ExportItem, ServiceRequest>(
});

if (compress) {
const dataStream = Readable.from(data);
const dataStream = readableFromBuffer(data);
pipeline(dataStream, gzip, req, onGzipError(onError));
} else {
req.write(data);
req.end();
}
}

function readableFromBuffer(buff: string | Buffer): Readable {
const readable = new Readable();
readable.push(buff);
readable.push(null);

return readable;
}

function onGzipError(onError: (error: collectorTypes.CollectorExporterError) => void) {
return (err: NodeJS.ErrnoException | null) => {
const error = new collectorTypes.CollectorExporterError(
Expand Down

0 comments on commit 62c11b4

Please sign in to comment.