Explorar o código

Merge branch 'master' into jpa-csh-tracing-end-time-from-fs

Christopher Hoskin %!s(int64=6) %!d(string=hai) anos
pai
achega
9437266dcb

+ 2 - 1
libraries/logger/.nvmrc

@@ -1 +1,2 @@
-10.19.0
+10.21.0
+

+ 0 - 2
libraries/logger/logging-manager.js

@@ -128,13 +128,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

+ 4 - 4
libraries/logger/package-lock.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "logger-sharelatex",
   "name": "logger-sharelatex",
-  "version": "1.9.0",
+  "version": "1.9.1",
   "lockfileVersion": 1,
   "lockfileVersion": 1,
   "requires": true,
   "requires": true,
   "dependencies": {
   "dependencies": {
@@ -140,9 +140,9 @@
       }
       }
     },
     },
     "@overleaf/o-error": {
     "@overleaf/o-error": {
-      "version": "2.1.0",
-      "resolved": "https://registry.npmjs.org/@overleaf/o-error/-/o-error-2.1.0.tgz",
-      "integrity": "sha512-Zd9sks9LrLw8ErHt/cXeWIkyxWAqNAvNGn7wIjLQJH6TTEEW835PWOhpch+hQwwWsTxWIx/JDj+IpZ3ouw925g=="
+      "version": "3.0.0",
+      "resolved": "https://registry.npmjs.org/@overleaf/o-error/-/o-error-3.0.0.tgz",
+      "integrity": "sha512-LsM2s6Iy9G97ktPo0ys4VxtI/m3ahc1ZHwjo5XnhXtjeIkkkVAehsrcRRoV/yWepPjymB0oZonhcfojpjYR/tg=="
     },
     },
     "@protobufjs/aspromise": {
     "@protobufjs/aspromise": {
       "version": "1.1.2",
       "version": "1.1.2",

+ 2 - 2
libraries/logger/package.json

@@ -7,7 +7,7 @@
     "url": "http://github.com/sharelatex/logger-sharelatex.git"
     "url": "http://github.com/sharelatex/logger-sharelatex.git"
   },
   },
   "license": "AGPL-3.0-only",
   "license": "AGPL-3.0-only",
-  "version": "1.9.0",
+  "version": "2.0.0",
   "scripts": {
   "scripts": {
     "test": "mocha test/**/*.js",
     "test": "mocha test/**/*.js",
     "format": "prettier-eslint '**/*.js' --list-different",
     "format": "prettier-eslint '**/*.js' --list-different",
@@ -16,7 +16,7 @@
   },
   },
   "dependencies": {
   "dependencies": {
     "@google-cloud/logging-bunyan": "^2.0.0",
     "@google-cloud/logging-bunyan": "^2.0.0",
-    "@overleaf/o-error": "^2.0.0",
+    "@overleaf/o-error": "^3.0.0",
     "bunyan": "1.8.12",
     "bunyan": "1.8.12",
     "raven": "1.1.3",
     "raven": "1.1.3",
     "yn": "^3.1.1"
     "yn": "^3.1.1"

+ 26 - 0
libraries/logger/test/unit/loggingManagerTests.js

@@ -259,6 +259,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() {