From 864daa84898ed2c51a1a6afadca16fd496980f36 Mon Sep 17 00:00:00 2001 From: Amean Asad Date: Tue, 27 Feb 2024 13:44:40 -0500 Subject: [PATCH] test/duplicatelogs (#62) * chore: disable hashring * fix test * test: duplicate log submission err handling * epxand try catch * refactor(client): move log cleanup into finally block --------- Co-authored-by: hannahhoward Co-authored-by: Andrew Gillis --- src/client.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/client.js b/src/client.js index 43e6c10..52f995e 100644 --- a/src/client.js +++ b/src/client.js @@ -476,20 +476,26 @@ export class Saturn { return } - const bandwidthLogs = this.hasPerformanceAPI - ? this._matchLogsWithPerformanceMetrics(this.logs) - : this.logs - - await fetch( - this.config.logURL, - { - method: 'POST', - body: JSON.stringify({ bandwidthLogs, logSender: this.config.logSender }) - } - ) + try { + const bandwidthLogs = this.hasPerformanceAPI + ? this._matchLogsWithPerformanceMetrics(this.logs) + : this.logs + + await fetch( + this.config.logURL, + { + method: 'POST', + body: JSON.stringify({ bandwidthLogs, logSender: this.config.logSender }) + } + ) + } catch (e) { + console.log(e) + throw e + } finally { + this.logs = [] + this._clearPerformanceBuffer() + } - this.logs = [] - this._clearPerformanceBuffer() } /**