Просмотр исходного кода

port leak fixes from smoke-test-sharelatex module

Brian Gough 11 лет назад
Родитель
Сommit
e51cdb81bd

+ 9 - 0
services/web/app/coffee/Features/HealthCheck/HealthCheckController.coffee

@@ -15,7 +15,16 @@ module.exports = HealthCheckController =
 			mocha = new Mocha(reporter: Reporter(res), timeout: 10000)
 			mocha.addFile("test/smoke/js/SmokeTests.js")
 			mocha.run () ->
+				# TODO: combine this with the smoke-test-sharelatex module
+				# we need to clean up all references to the smokeTest module
+				# so it can be garbage collected.  The only reference should
+				# be in its parent, when it is loaded by mocha.addFile.
 				path = require.resolve(__dirname + "/../../../../test/smoke/js/SmokeTests.js")
+				smokeTestModule = require.cache[path]
+				parent = smokeTestModule.parent
+				while (idx = parent.children.indexOf(smokeTestModule)) != -1
+					parent.children.splice(idx, 1)
+				# remove the smokeTest from the module cache
 				delete require.cache[path]
 
 	checkRedis: (req, res, next)->

+ 1 - 1
services/web/test/smoke/coffee/SmokeTests.coffee

@@ -2,7 +2,7 @@ child   = require "child_process"
 fs = require "fs"
 assert = require("assert")
 chai = require("chai")
-chai.should()
+chai.should() unless Object.prototype.should?
 expect = chai.expect
 Settings = require "settings-sharelatex"
 port = Settings.internal?.web?.port or Settings.port or 3000