@cap-js-community/event-queue 0.1.52 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js-community/event-queue",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "description": "event queue for cds",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -2,6 +2,8 @@
2
2
 
3
3
  const COMPONENT = "eventQueue/SetIntervalDriftSafe";
4
4
 
5
+ const ALLOWED_SHIFT_IN_PROCENT = 0.1;
6
+
5
7
  class SetIntervalDriftSafe {
6
8
  #adjustedInterval;
7
9
  #interval;
@@ -19,8 +21,11 @@ class SetIntervalDriftSafe {
19
21
  const now = Date.now();
20
22
  if (this.#expectedCycleTime === 0) {
21
23
  this.#expectedCycleTime = now + this.#interval;
22
- } else if (now + this.#interval - this.#nextTickScheduledFor < this.#interval) {
23
- this.#logger.info("overlapping ticks, skipping this run");
24
+ } else if (
25
+ Math.abs(now + this.#interval - this.#nextTickScheduledFor - this.#interval) >
26
+ this.#interval * ALLOWED_SHIFT_IN_PROCENT
27
+ ) {
28
+ this.#logger.log("overlapping ticks, skipping this run");
24
29
  return;
25
30
  } else {
26
31
  this.#adjustedInterval = this.#interval - (now - this.#expectedCycleTime);