Skip to content

Commit

Permalink
[REFACTOR][AOM2-172] Sleep for a random millisecond instead of micros…
Browse files Browse the repository at this point in the history
…econd to avoid the difference being smaller than the save time, which would result in duplicate CSP reports.
  • Loading branch information
borisvankatwijk committed Aug 12, 2021
1 parent e6114c1 commit a3c6e13
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Model/ReportRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public function save(
// @TODO: [Nice to have] Find the reason csp reports are sent directly at the same time, to prevent having to
// to use the usleep() mechanic to de-synchronise saving.

// Sleep for a random microsecond to prevent double saves
$sleep = rand(1, 1000000);
// Sleep for a random millisecond to prevent double saves
$sleep = rand(1000, 1000000);
usleep($sleep);
$existingReport = $this->doesReportExistAlready($report);

Expand Down

0 comments on commit a3c6e13

Please sign in to comment.