diff --git a/packages/kbn-es-archiver/src/actions/load.ts b/packages/kbn-es-archiver/src/actions/load.ts index efb1fe9f9ea54a..c2f5f18a07e9b7 100644 --- a/packages/kbn-es-archiver/src/actions/load.ts +++ b/packages/kbn-es-archiver/src/actions/load.ts @@ -43,7 +43,7 @@ import { // are not listened for const pipeline = (...streams: Readable[]) => streams.reduce((source, dest) => - source.once('error', (error) => dest.emit('error', error)).pipe(dest as any) + source.once('error', (error) => dest.destroy(error)).pipe(dest as any) ); export async function loadAction({ diff --git a/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.test.js b/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.test.js index b742a770b70c81..878d645d9b4a79 100644 --- a/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.test.js +++ b/packages/kbn-es-archiver/src/lib/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/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.ts b/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.ts index 4794d76cc7f846..be0768316b2930 100644 --- a/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.ts +++ b/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.ts @@ -50,7 +50,7 @@ export function concatStreamProviders( 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/core/server/utils/streams/concat_stream_providers.test.ts b/src/core/server/utils/streams/concat_stream_providers.test.ts index b742a770b70c81..878d645d9b4a79 100644 --- a/src/core/server/utils/streams/concat_stream_providers.test.ts +++ b/src/core/server/utils/streams/concat_stream_providers.test.ts @@ -44,7 +44,7 @@ describe('concatStreamProviders() helper', () => { () => new Readable({ read() { - this.emit('error', new Error('foo')); + this.destroy(new Error('foo')); }, }), ]); diff --git a/src/core/server/utils/streams/concat_stream_providers.ts b/src/core/server/utils/streams/concat_stream_providers.ts index bb836e3d737872..236d68c89707e4 100644 --- a/src/core/server/utils/streams/concat_stream_providers.ts +++ b/src/core/server/utils/streams/concat_stream_providers.ts @@ -54,7 +54,7 @@ export function concatStreamProviders( 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/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts b/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts index 1cec7b769fa26b..d1a8e93bff9292 100644 --- a/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts +++ b/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts @@ -283,7 +283,7 @@ describe('copySavedObjectsToSpaces', () => { new Readable({ objectMode: true, read() { - this.emit('error', new Error('Something went wrong while reading this stream')); + this.destroy(new Error('Something went wrong while reading this stream')); }, }) ); diff --git a/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts b/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts index 37181c9d81649d..f1b475ee9d1b3d 100644 --- a/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts +++ b/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts @@ -290,7 +290,7 @@ describe('resolveCopySavedObjectsToSpacesConflicts', () => { new Readable({ objectMode: true, read() { - this.emit('error', new Error('Something went wrong while reading this stream')); + this.destroy(new Error('Something went wrong while reading this stream')); }, }) );