From 33864608389865f3a5008146a74a32b3150d7e43 Mon Sep 17 00:00:00 2001 From: moda20 Date: Wed, 27 Apr 2022 08:40:35 +0100 Subject: [PATCH] add timed delays for attribute resolution --- utilities/assets-proxy-path.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/utilities/assets-proxy-path.js b/utilities/assets-proxy-path.js index 4b643de..b1fe535 100644 --- a/utilities/assets-proxy-path.js +++ b/utilities/assets-proxy-path.js @@ -105,15 +105,18 @@ class AssetsProxyPath { let body = { status: 'PENDING' } + let milestonesDate = new Date().getTime(); let response = request('GET', `${this.nodeBaseUrl}/resolve?ids=${id}`); - const handler = JSON.parse(response.getBody()).handler_id + const handler = JSON.parse(response.getBody()).handler_id; while (body.status === 'PENDING') { - new Date(new Date().getTime() + 1000); - response = request('GET', `${this.nodeBaseUrl}/resolve/result/${handler}`); - body = JSON.parse(response.getBody()); + if((new Date().getTime()) > milestonesDate + 1000){ + new Date(new Date().getTime() + 1000); + response = request('GET', `${this.nodeBaseUrl}/resolve/result/${handler}`); + body = JSON.parse(response.getBody()); + } } return body.data[0].result; } } -module.exports = AssetsProxyPath; \ No newline at end of file +module.exports = AssetsProxyPath;