From 1501f98f9ba5bb3c154045c003b3f573f5e7a868 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 24 Nov 2013 01:04:45 +0000 Subject: [PATCH] limit the number of player names resolved in one go, to prevent excessive requests for #656 number 4 --- code/player_names.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/player_names.js b/code/player_names.js index 7914c706..e9475a03 100644 --- a/code/player_names.js +++ b/code/player_names.js @@ -66,6 +66,12 @@ window.resolvePlayerNames = function() { //limit per request. stock site is never more than 13 (8 res, 4 mods, owner) //testing shows 15 works and 20 fails var MAX_RESOLVE_PLAYERS_PER_REQUEST = 15; + var MAX_RESOLVE_REQUESTS = 8; + + if (window.playersToResolve.length > MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS) { + console.log('Warning: player name resolve queue had '+window.playersToResolve.length+' entries. Limiting to the first '+MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS+' to prevent excessive requests'); + window.playersToResolve = playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS); + } var p = window.playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST); window.playersToResolve = playersToResolve.slice(MAX_RESOLVE_PLAYERS_PER_REQUEST);