Skip to content

Commit

Permalink
test/duplicatelogs (#62)
Browse files Browse the repository at this point in the history
* 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 <hannah@hannahhoward.net>
Co-authored-by: Andrew Gillis <gammazero@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 27, 2024
1 parent 1de2e94 commit 864daa8
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

/**
Expand Down

0 comments on commit 864daa8

Please sign in to comment.