Skip to content

Commit

Permalink
do not get overwhelmed by output (#295)
Browse files Browse the repository at this point in the history
* do not get overwhelmed by output

* fixup
  • Loading branch information
mcollina authored Dec 17, 2018
1 parent 5ad7413 commit 498fab2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions format/abstract-decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AbstractDecoder extends stream.Transform {
this._bufferedLength = 0
this._nextMessageLength = FRAME_PREFIX_SIZE
this._awaitFramePrefix = true
this._warned = false
}

_transform (chunk, encoding, callback) {
Expand Down Expand Up @@ -44,9 +45,12 @@ class AbstractDecoder extends stream.Transform {
msg
)
} catch (_) {
console.error('There was a decoding error with chunk (base64):')
console.error(chunk.toString('base64'))
console.error('Please open an issue on https://github.com/nearform/node-clinic-bubbleprof with the above output.')
if (!this._warned) {
console.error('There was a decoding error with chunk (base64):')
console.error(chunk.toString('base64'))
console.error('Please open an issue on https://github.com/nearform/node-clinic-bubbleprof with the above output.')
this._warned = true
}
}
chunk = chunk.slice(this._nextMessageLength)
this._nextMessageLength = FRAME_PREFIX_SIZE
Expand Down

0 comments on commit 498fab2

Please sign in to comment.