fix: adjust task delay threshold to 9 hours

Updates the maximum delay for direct task queuing to 9 hours. This change ensures that tasks with delays exceeding this threshold are stored in KV for later processing.

The update also reflects the new delay threshold in the unit tests.
This commit is contained in:
2025-12-16 08:28:14 -05:00
parent 9b17f5bcfe
commit 1501aff3b6
2 changed files with 14 additions and 15 deletions

View File

@@ -40,17 +40,16 @@ export async function queueTask(
req?.header(),
);
const MAX_DELAY_SECONDS = 12 * 60 * 60; // 43,200 seconds (12 hours)
const MAX_DELAY_SECONDS = Duration.fromObject({ hours: 9 }).as("seconds");
// If delay exceeds 12 hours, store in KV for later processing
// If delay exceeds 9 hours, store in KV for later processing
if (scheduleTime > MAX_DELAY_SECONDS) {
if (!env || !env.DELAYED_TASKS) {
throw new Error("DELAYED_TASKS KV namespace not available");
}
const { generateTaskKey, serializeDelayedTask } = await import(
"./delayedTask"
);
const { generateTaskKey, serializeDelayedTask } =
await import("./delayedTask");
const taskId = crypto.randomUUID();
const scheduledEpochTime = Math.floor(Date.now() / 1000) + scheduleTime;