From 32c36a4f9c3a21d3a3e8b06dec52ab5a4962ebfe Mon Sep 17 00:00:00 2001 From: Nikolay Kharitonov Date: Sat, 18 Nov 2023 20:39:51 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20fix=20potential=20cpu=20leak?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game/game.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/game.js b/src/game/game.js index f9506004..579a2b49 100644 --- a/src/game/game.js +++ b/src/game/game.js @@ -6,7 +6,8 @@ C = driver.constants, map = require('./map'), market = require('./market'), - customPrototypes = require('./custom-prototypes'); + customPrototypes = require('./custom-prototypes'), + system = { Function: { bind: Function.bind } }; var findCacheFn = { [C.FIND_CREEPS]: (i) => !i.spawning, @@ -505,7 +506,7 @@ !_.isObject(runCodeCache[userId].globals.require.cache.main) || !_.isFunction( runCodeCache[userId].globals.require.cache.main.loop)) { - runCodeCache[userId].globals.require = requireFn.bind(runCodeCache[userId]); + runCodeCache[userId].globals.require = system.Function.bind.call(requireFn, runCodeCache[userId]); runCodeCache[userId].globals.require.cache = {lodash: runCodeCache[userId].globals._}; runCodeCache[userId].globals.require.timestamp = runCodeCache[userId].runtimeData.userCodeTimestamp; }