diff --git a/src/es_archiver/actions/load.js b/src/es_archiver/actions/load.js index cc3cf8f789b043..f3ea7f19f54654 100644 --- a/src/es_archiver/actions/load.js +++ b/src/es_archiver/actions/load.js @@ -42,7 +42,7 @@ import { const pipeline = (...streams) => streams .reduce((source, dest) => ( source - .once('error', (error) => dest.emit('error', error)) + .once('error', (error) => dest.destroy(error)) .pipe(dest) )); diff --git a/src/optimize/public_path_placeholder.js b/src/optimize/public_path_placeholder.js index e40a9b4ba75913..c4e60798bd50e0 100644 --- a/src/optimize/public_path_placeholder.js +++ b/src/optimize/public_path_placeholder.js @@ -35,7 +35,7 @@ export function replacePlaceholder(read, replacement) { takeUntil(Rx.fromEvent(read, 'end')) ) .forEach(error => { - replace.emit('error', error); + replace.destroy(error); replace.end(); }); diff --git a/src/utils/streams/concat_stream_providers.js b/src/utils/streams/concat_stream_providers.js index adbbcf9a0d5f9d..db977d8716fffd 100644 --- a/src/utils/streams/concat_stream_providers.js +++ b/src/utils/streams/concat_stream_providers.js @@ -51,7 +51,7 @@ export function concatStreamProviders(sourceProviders, options = {}) { source // proxy errors from the source to the destination - .once('error', (error) => destination.emit('error', error)) + .once('error', (error) => destination.destroy(error)) // pipe the source to the destination but only proxy the // end event if this is the last source .pipe(destination, { end: isLast }); diff --git a/src/utils/streams/concat_stream_providers.test.js b/src/utils/streams/concat_stream_providers.test.js index f3997998c967bd..8f74a9a1353bfe 100644 --- a/src/utils/streams/concat_stream_providers.test.js +++ b/src/utils/streams/concat_stream_providers.test.js @@ -44,7 +44,7 @@ describe('concatStreamProviders() helper', () => { () => new Readable({ read() { - this.emit('error', new Error('foo')); + this.destroy(new Error('foo')); }, }), ]); diff --git a/x-pack/plugins/reporting/server/browsers/download/download.test.js b/x-pack/plugins/reporting/server/browsers/download/download.test.js index 61b505703a7516..76dc71a5ffde0c 100644 --- a/x-pack/plugins/reporting/server/browsers/download/download.test.js +++ b/x-pack/plugins/reporting/server/browsers/download/download.test.js @@ -22,7 +22,7 @@ jest.mock('request', () => { return new Readable({ read() { if (resp instanceof Error) { - this.emit('error', resp); + this.destroy(resp); return; }