summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit/cron_test.ts19
-rw-r--r--cli/tsc/dts/lib.deno.unstable.d.ts31
2 files changed, 15 insertions, 35 deletions
diff --git a/cli/tests/unit/cron_test.ts b/cli/tests/unit/cron_test.ts
index 8408acf45..ed4500624 100644
--- a/cli/tests/unit/cron_test.ts
+++ b/cli/tests/unit/cron_test.ts
@@ -297,13 +297,13 @@ Deno.test(async function retriesWithBackoffScheduleOldApi() {
let count = 0;
const ac = new AbortController();
- const c = Deno.cron("abc2", "*/20 * * * *", async () => {
+ const c = Deno.cron("abc2", "*/20 * * * *", {
+ signal: ac.signal,
+ backoffSchedule: [10, 20],
+ }, async () => {
count += 1;
await sleep(10);
throw new TypeError("cron error");
- }, {
- signal: ac.signal,
- backoffSchedule: [10, 20],
});
try {
@@ -380,3 +380,14 @@ Deno.test("Parse schedule to string - string", () => {
const result = parseScheduleToString("* * * * *");
assertEquals(result, "* * * * *");
});
+
+Deno.test("error on two handlers", () => {
+ assertThrows(
+ () => {
+ // @ts-ignore test
+ Deno.cron("abc", "* * * * *", () => {}, () => {});
+ },
+ TypeError,
+ "Deno.cron requires a single handler",
+ );
+});
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index 9cbfe2bfa..80bb4e327 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -1265,37 +1265,6 @@ declare namespace Deno {
/** **UNSTABLE**: New API, yet to be vetted.
*
- * Create a cron job that will periodically execute the provided handler
- * callback based on the specified schedule.
- *
- * `schedule` can be a string in the Unix cron format or in JSON format
- * as specified by interface {@linkcode CronSchedule}, where time is specified
- * using UTC time zone.
- *
- * ```ts
- * Deno.cron("sample cron", "20 * * * *", () => {
- * console.log("cron job executed");
- * });
- * ```
- * `backoffSchedule` option can be used to specify the retry policy for failed
- * executions. Each element in the array represents the number of milliseconds
- * to wait before retrying the execution. For example, `[1000, 5000, 10000]`
- * means that a failed execution will be retried at most 3 times, with 1
- * second, 5 seconds, and 10 seconds delay between each retry.
- *
- * @category Cron
- * @deprecated Use other {@linkcode cron} overloads instead. This overload
- * will be removed in the future.
- */
- export function cron(
- name: string,
- schedule: string | CronSchedule,
- handler: () => Promise<void> | void,
- options: { backoffSchedule?: number[]; signal?: AbortSignal },
- ): Promise<void>;
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
* A key to be persisted in a {@linkcode Deno.Kv}. A key is a sequence
* of {@linkcode Deno.KvKeyPart}s.
*