Skip to content

Commit

Permalink
Never manually emit errors on streams
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Jun 8, 2021
1 parent 8bc69b0 commit 17d689b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/es_archiver/actions/load.js
Expand Up @@ -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)
));

Expand Down
2 changes: 1 addition & 1 deletion src/optimize/public_path_placeholder.js
Expand Up @@ -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();
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/streams/concat_stream_providers.js
Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion src/utils/streams/concat_stream_providers.test.js
Expand Up @@ -44,7 +44,7 @@ describe('concatStreamProviders() helper', () => {
() =>
new Readable({
read() {
this.emit('error', new Error('foo'));
this.destroy(new Error('foo'));
},
}),
]);
Expand Down
Expand Up @@ -22,7 +22,7 @@ jest.mock('request', () => {
return new Readable({
read() {
if (resp instanceof Error) {
this.emit('error', resp);
this.destroy(resp);
return;
}

Expand Down

0 comments on commit 17d689b

Please sign in to comment.