From 4651ab60bab455e059e07b46fcfdcc387a5237e9 Mon Sep 17 00:00:00 2001 From: Peter Flannery Date: Wed, 25 Mar 2015 00:24:59 +0000 Subject: [PATCH] fixes snapshot leakage and ensures file buffers are cleaned up --- es6/test/util.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/es6/test/util.js b/es6/test/util.js index 695ea71..9b501a9 100644 --- a/es6/test/util.js +++ b/es6/test/util.js @@ -18,7 +18,9 @@ util.saveSnapshot = function (testname, next) { result += data // not a buffer } let complete = function () { - fs.writeFile(filename, result, next) + fs.writeFileSync(filename, result) + snapshot.delete(); + next(); } snapshot.serialize(concatIterator, complete) } @@ -31,7 +33,8 @@ util.stopProfile = function (testname, next) { let filename = testname+'.cpuprofile' let cpuProfile = profiler.stopProfiling(testname) let profileJSON = JSON.stringify(cpuProfile) - + cpuProfile.delete(); + next = next || function(error){ if ( error ) return console.error(error) console.log('Profile taken successfully:', filename) @@ -41,6 +44,8 @@ util.stopProfile = function (testname, next) { profileJSON = profileJSON.replace(/"bailoutReason":/g, '"deoptReason":') // Write the file - fs.writeFile(filename, profileJSON, next) + fs.writeFileSync(filename, profileJSON) + + next(); } module.exports = util