[PM-6426] Using the getUpperBoundDelayInMinutes method to handle setting stepped alarms and setTimeout fallbacks

This commit is contained in:
Cesar Gonzalez 2024-05-10 13:31:41 -05:00
parent 478b8e6f13
commit 2ae0296b2e
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
1 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ export class BrowserTaskSchedulerServiceImplementation
// If the delay is less than a minute, we want to attempt to trigger the task through a setTimeout.
// The alarm previously scheduled will be used as a backup in case the setTimeout fails.
if (delayInMinutes < 1) {
if (delayInMinutes < this.getUpperBoundDelayInMinutes(delayInMinutes)) {
return globalThis.setTimeout(async () => {
await this.clearScheduledAlarm(taskName);
await this.triggerTask(taskName);
@ -93,7 +93,7 @@ export class BrowserTaskSchedulerServiceImplementation
? initialDelayInMs / 1000 / 60
: intervalInMinutes;
if (intervalInMinutes < 1) {
if (intervalInMinutes < this.getUpperBoundDelayInMinutes(intervalInMinutes)) {
return this.setupSteppedIntervalAlarms(taskName, intervalInMs);
}