Skip to content

Commit dce356c

Browse files
author
Dushyant Bhalgami
authored
Merge pull request #166 from topcoder-platform/hotfix_memory_issue
Hotfix memory issue
2 parents 331b0db + 7a72a02 commit dce356c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

app.js

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const swaggerUi = require('swagger-ui-express')
1818
const YAML = require('yamljs')
1919
const authenticator = require('tc-core-library-js').middleware.jwtAuthenticator
2020
const fileUpload = require('express-fileupload')
21+
const memwatch = require('memwatch-next')
2122

2223
const swaggerDocument = YAML.load('./docs/swagger.yaml')
2324
const app = express()
@@ -30,6 +31,19 @@ app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }))
3031
app.use(cors())
3132
app.use(fileUpload())
3233

34+
memwatch.on('leak', function (info) {
35+
winston.info(`Memory leak detected, details: ${info}`)
36+
const reqBody = {
37+
topic: 'common.error.reporting',
38+
originator: 'submission-api',
39+
timestamp: (new Date()).toISOString(), // time when submission was created
40+
'mime-type': 'application/json',
41+
payload: info
42+
}
43+
44+
helper.postToBusApi(reqBody)
45+
})
46+
3347
const apiRouter = express.Router()
3448

3549
/**

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"http-status": "^1.2.0",
3838
"joi": "^13.4.0",
3939
"lodash": "^4.17.15",
40+
"memwatch-next": "^0.3.0",
4041
"superagent": "^3.8.3",
4142
"swagger-ui-express": "^3.0.10",
4243
"tc-bus-api-wrapper": "topcoder-platform/tc-bus-api-wrapper.git#feature/auth0-proxy-server",

0 commit comments

Comments
 (0)