Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 avoid useless debug message #411

Merged
merged 2 commits into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions packages/core/src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ function createErrorWith(error, index, funcName, funcParams, chunk) {
chunk,
});
Error.captureStackTrace(err, createErrorWith);
debug('ezs')('Caught an', err);
return err;
}

Expand Down Expand Up @@ -169,8 +168,10 @@ export default class Engine extends SafeTransform {
}
const warn = (error) => {
if (!this.errorWasSent) {
this.errorWasSent = true;
this.emit('error', createErrorWith(error, currentIndex, this.funcName, this.params, chunk));
this.errorWasSent = true;
const warnErr = createErrorWith(error, currentIndex, this.funcName, this.params, chunk);
debug('ezs')('ezs engine emit an', warnErr);
this.emit('error', warnErr);
}
};
const push = (data) => {
Expand All @@ -185,8 +186,9 @@ export default class Engine extends SafeTransform {
return warn(new Error('No back pressure control ?'));
}
if (data instanceof Error) {
debug('ezs')(`Ignoring error at item #${currentIndex}`);
return this.push(createErrorWith(data, currentIndex, this.funcName, this.params, chunk));
const ignoreErr = createErrorWith(data, currentIndex, this.funcName, this.params, chunk);
debug('ezs')(`Ignoring error at item #${currentIndex}`, ignoreErr);
return this.push(ignoreErr);
}
if (!this.errorWasSent) {
return this.push(data);
Expand All @@ -202,13 +204,15 @@ export default class Engine extends SafeTransform {
try {
this.chunk = chunk;
return Promise.resolve(this.func.call(this.scope, chunk, feed, this.scope)).catch((e) => {
debug('ezs')(`Async error thrown at item #${currentIndex}, pipeline is broken`);
this.emit('error', createErrorWith(e, currentIndex, this.funcName, this.params, chunk));
const asyncErr = createErrorWith(e, currentIndex, this.funcName, this.params, chunk);
debug('ezs')(`Async error thrown at item #${currentIndex}, pipeline is broken`, asyncErr);
this.emit('error', asyncErr);
done();
});
} catch (e) {
debug('ezs')(`Sync error thrown at item #${currentIndex}, pipeline carries errors`);
this.push(createErrorWith(e, currentIndex, this.funcName, this.params, chunk));
const syncErr = createErrorWith(e, currentIndex, this.funcName, this.params, chunk);
debug('ezs')(`Sync error thrown at item #${currentIndex}, pipeline carries errors`, syncErr);
this.push(syncErr);
return done();
}
}
Expand Down
Loading