[ObsUX][Synthtrace] Replace multistream use with own util method (#203988)

## Summary

A whole dependency was being pulled in for doing something that could
easily be done just using Node.js own utils and be made into a simple
method. As such, `multistream` has been removed since there is no other
place in the codebase that is using it.

## How to test

* Load Kibana local dev environment using synthtrace data/scenarios. No
scenario should fail to load normally, and all tests using synthtrace
data should pass as expected.

Closes #203860
This commit is contained in:
Gonçalo Rica Pais da Silva 2024-12-12 16:28:19 +01:00 committed by GitHub
parent 2ab8a5ced0
commit d9f8f170ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 20 deletions

View file

@ -1621,7 +1621,6 @@
"@types/minimist": "^1.2.5",
"@types/mock-fs": "^4.13.1",
"@types/moment-duration-format": "^2.2.3",
"@types/multistream": "^4.1.0",
"@types/mustache": "^0.8.31",
"@types/nock": "^10.0.3",
"@types/node": "20.10.5",
@ -1798,7 +1797,6 @@
"mock-fs": "^5.1.2",
"ms-chromium-edge-driver": "^0.5.1",
"msw": "^2.4.12",
"multistream": "^4.1.0",
"mutation-observer": "^1.0.3",
"native-hdr-histogram": "^1.0.0",
"nock": "12.0.3",

View file

@ -8,11 +8,29 @@
*/
import { eachSeries } from 'async';
import MultiStream from 'multistream';
import { Duplex, Readable, Transform } from 'stream';
import { Duplex, Readable, Transform, PassThrough } from 'stream';
/**
* Pipe one or many streams sequentially into the destination stream. Once all
* source streams have been exhausted, the destination stream is ended.
* @param sources A collection of streams to read from
* @param destination The stream to pipe data to
*/
async function combineStreams(sources: Readable[], destination: PassThrough) {
for (const stream of sources) {
await new Promise((resolve, reject) => {
stream.on('end', resolve);
stream.on('error', reject);
stream.pipe(destination, { end: false });
});
}
destination.emit('end');
}
export function sequential(...streams: Readable[]) {
return new MultiStream(streams, { objectMode: true });
const output = new PassThrough({ objectMode: true });
combineStreams(streams, output).catch((err) => output.destroy(err));
return output;
}
export function fork(...streams: Transform[]): Duplex {

View file

@ -11937,13 +11937,6 @@
dependencies:
moment ">=2.14.0"
"@types/multistream@^4.1.0":
version "4.1.0"
resolved "https://registry.yarnpkg.com/@types/multistream/-/multistream-4.1.0.tgz#517770a32e5715fdda87904a6da7d179142feba4"
integrity sha512-KiMkWve/Uu0qwCtNO6ZflMLjglkXsAdLdIwb31o5YQBbevdH2DF7inqebCli+F9am8McvEqCE4GXNOUZe8jOAg==
dependencies:
"@types/node" "*"
"@types/mustache@^0.8.31":
version "0.8.31"
resolved "https://registry.yarnpkg.com/@types/mustache/-/mustache-0.8.31.tgz#7c86cbf74f7733f9e3bdc28817623927eb386616"
@ -24796,14 +24789,6 @@ multipipe@^1.0.2:
duplexer2 "^0.1.2"
object-assign "^4.1.0"
multistream@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/multistream/-/multistream-4.1.0.tgz#7bf00dfd119556fbc153cff3de4c6d477909f5a8"
integrity sha512-J1XDiAmmNpRCBfIWJv+n0ymC4ABcf/Pl+5YvC5B/D2f/2+8PtHvCNxMPKiQcZyi922Hq69J2YOpb1pTywfifyw==
dependencies:
once "^1.4.0"
readable-stream "^3.6.0"
murmurhash-js@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/murmurhash-js/-/murmurhash-js-1.0.0.tgz#b06278e21fc6c37fa5313732b0412bcb6ae15f51"