Skip to content

Commit 36cded7

Browse files
committed
better docs for options
1 parent fb4138a commit 36cded7

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

internal-packages/run-engine/src/engine/tests/debounce.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ describe("RunEngine debounce", () => {
480480

481481
await setupBackgroundWorker(engine, authenticatedEnvironment, taskIdentifier);
482482

483-
// First trigger with 500ms delay
483+
// First trigger with 1s delay
484484
const run = await engine.trigger(
485485
{
486486
number: 1,
@@ -497,10 +497,10 @@ describe("RunEngine debounce", () => {
497497
queue: "task/test-task",
498498
isTest: false,
499499
tags: [],
500-
delayUntil: new Date(Date.now() + 500),
500+
delayUntil: new Date(Date.now() + 1000),
501501
debounce: {
502502
key: "user-123",
503-
delay: "500ms",
503+
delay: "1s",
504504
},
505505
},
506506
prisma
@@ -512,7 +512,7 @@ describe("RunEngine debounce", () => {
512512
expect(executionData.snapshot.executionStatus).toBe("DELAYED");
513513

514514
// Wait for delay to pass
515-
await setTimeout(1000);
515+
await setTimeout(1500);
516516

517517
// Should now be QUEUED
518518
executionData = await engine.getRunExecutionData({ runId: run.id });

packages/core/src/v3/types/tasks.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,13 +920,17 @@ export type TriggerOptions = {
920920
debounce?: {
921921
/**
922922
* Unique key scoped to the task identifier. Runs with the same key will be debounced together.
923+
* Maximum length is 512 characters.
923924
*/
924925
key: string;
925926
/**
926927
* Duration string specifying how long to delay the run. If another trigger with the same key
927928
* occurs within this duration, the delay is extended.
928929
*
929-
* @example "5s", "1m", "30s"
930+
* Supported formats: `{number}s` (seconds), `{number}m` (minutes), `{number}h` (hours),
931+
* `{number}d` (days), `{number}w` (weeks). Minimum delay is 1 second.
932+
*
933+
* @example "1s", "5s", "1m", "30m", "1h"
930934
*/
931935
delay: string;
932936
};

references/hello-world/src/trigger/debounce.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ export const parentWithDebouncedChild = task({
523523
export const shortDebounce = task({
524524
id: "short-debounce",
525525
run: async (payload: { key: string }) => {
526-
logger.info("Short debounce task (500ms)", { key: payload.key });
527-
return { key: payload.key, delay: "500ms" };
526+
logger.info("Short debounce task (1s)", { key: payload.key });
527+
return { key: payload.key, delay: "1s" };
528528
},
529529
});
530530

@@ -549,10 +549,10 @@ export const testDifferentDelays = task({
549549
run: async (payload: { key: string }) => {
550550
logger.info("Testing different debounce delays", { key: payload.key });
551551

552-
// 500ms debounce - good for rapid UI updates
552+
// 1 second debounce - good for rapid UI updates
553553
await shortDebounce.trigger(
554554
{ key: `${payload.key}-short` },
555-
{ debounce: { key: `${payload.key}-short`, delay: "500ms" } }
555+
{ debounce: { key: `${payload.key}-short`, delay: "1s" } }
556556
);
557557

558558
// 5 second debounce - good for user input

0 commit comments

Comments
 (0)