Skip to content

Commit

Permalink
[fix] Wrap calls to format.transform with try / catch. Potential fi…
Browse files Browse the repository at this point in the history
…x for #1261.
  • Loading branch information
indexzero committed Jun 1, 2018
1 parent 0c84f4f commit baaa9c7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,17 @@ class Logger extends stream.Transform {
}

// Here we write to the `format` pipe-chain, which on `readable` above will
// push the formatted `info` Object onto the buffer for this instance.
this.push(this.format.transform(info, this.format.options));
callback();
// push the formatted `info` Object onto the buffer for this instance. We trap
// (and re-throw) any errors generated by the user-provided format, but also
// guarantee that the streams callback is invoked so that we can continue flowing.
try {
this.push(this.format.transform(info, this.format.options));
} catch (ex) {
throw ex;
} finally {
// eslint-disable-next-line callback-return
callback();
}
}

/**
Expand Down

0 comments on commit baaa9c7

Please sign in to comment.