mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[misc] fix decaff cleanup for reportedToSentry
Previously it would bailout of the loop after processing ANY attribute. REF: 6fe4dcbf32720282821d42140ab92593866e0772
This commit is contained in:
parent
7be3c208fd
commit
b049331777
2 changed files with 26 additions and 2 deletions
|
@ -134,13 +134,11 @@ const Logger = (module.exports = {
|
||||||
this.raven.captureException(error, { tags, extra, level })
|
this.raven.captureException(error, { tags, extra, level })
|
||||||
|
|
||||||
// put a flag on the errors to avoid reporting them multiple times
|
// put a flag on the errors to avoid reporting them multiple times
|
||||||
const result = []
|
|
||||||
for (key in attributes) {
|
for (key in attributes) {
|
||||||
value = attributes[key]
|
value = attributes[key]
|
||||||
if (value instanceof Error) {
|
if (value instanceof Error) {
|
||||||
value.reportedToSentry = true
|
value.reportedToSentry = true
|
||||||
}
|
}
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// ignore Raven errors
|
// ignore Raven errors
|
||||||
|
|
|
@ -257,6 +257,32 @@ describe('LoggingManager', function() {
|
||||||
this.logger.error({ foo: 'bar' }, 'message')
|
this.logger.error({ foo: 'bar' }, 'message')
|
||||||
this.captureException.callCount.should.equal(10)
|
this.captureException.callCount.should.equal(10)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('reportedToSentry', function() {
|
||||||
|
it('should mark the error as reported to sentry', function() {
|
||||||
|
const err = new Error()
|
||||||
|
this.logger.error({ err }, 'message')
|
||||||
|
expect(this.captureException.called).to.equal(true)
|
||||||
|
expect(err.reportedToSentry).to.equal(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should mark two errors as reported to sentry', function() {
|
||||||
|
const err1 = new Error()
|
||||||
|
const err2 = new Error()
|
||||||
|
this.logger.error({ err: err1, err2 }, 'message')
|
||||||
|
expect(this.captureException.called).to.equal(true)
|
||||||
|
expect(err1.reportedToSentry).to.equal(true)
|
||||||
|
expect(err2.reportedToSentry).to.equal(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should not mark arbitrary objects as reported to sentry', function() {
|
||||||
|
const err = new Error()
|
||||||
|
const ctx = { foo: 'bar' }
|
||||||
|
this.logger.error({ err, ctx }, 'message')
|
||||||
|
expect(this.captureException.called).to.equal(true)
|
||||||
|
expect(ctx.reportedToSentry).to.equal(undefined)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('checkLogLevel', function() {
|
describe('checkLogLevel', function() {
|
||||||
|
|
Loading…
Reference in a new issue