Skip to content

Commit

Permalink
Modified span error reporting so that it will not log an error when a…
Browse files Browse the repository at this point in the history
… connection is aborted.
  • Loading branch information
ronilan committed Mar 21, 2022
1 parent 98818c7 commit cde9e2d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,18 @@ function isRealObject (v) {
Span.prototype.error = function (error) {
log.span(`span.error on ${this.name}`)

// when there is an aborted incoming request (e.g. user pressed stop in their browser)
// the error will be on top span and there will be no lastEvent.
// (note:there can also be an aborted connection on an outgoing request on a lower span)
// reporting error (via _internal method of span) without lastEvent will fail.
// that failure will create an error level log entry.
// logging an "error in reporting an error" is too much and leads to end user confusion.
// thus, log the issue at the span level and return gracefully.
if (this.topSpan && error && error.code === 'ECONNRESET') {
log.span('Connection reset', error)
return
}

try {
const orig = error
error = Span.toError(error)
Expand Down

0 comments on commit cde9e2d

Please sign in to comment.