{"record":{"id":"0b41650cea49b525","repo":"denoland/deno","slug":"cannot-create-cron-job-a-single-handler-is-requir","errorCode":null,"errorMessage":"Cannot create cron job, a single handler is required: two handlers were specified","messagePattern":"Cannot create cron job, a single handler is required: two handlers were specified","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/cron/01_cron.ts","lineNumber":137,"sourceCode":"    );\n  }\n  if (schedule === undefined) {\n    throw new TypeError(\n      \"Cannot create cron job, a schedule is required: received 'undefined'\",\n    );\n  }\n\n  schedule = parseScheduleToString(schedule);\n\n  let handler: () => Promise<void> | void;\n  let options:\n    | { backoffSchedule?: number[]; signal?: AbortSignal }\n    | undefined = undefined;\n\n  if (typeof handlerOrOptions1 === \"function\") {\n    handler = handlerOrOptions1;\n    if (handler2 !== undefined) {\n      throw new TypeError(\n        \"Cannot create cron job, a single handler is required: two handlers were specified\",\n      );\n    }\n  } else if (typeof handler2 === \"function\") {\n    handler = handler2;\n    options = handlerOrOptions1;\n  } else {\n    throw new TypeError(\"Cannot create cron job: a handler is required\");\n  }\n\n  const rid = op_cron_create(\n    name,\n    schedule,\n    options?.backoffSchedule,\n  );\n\n  if (options?.signal) {\n    const signal = options?.signal;","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/cron/01_cron.ts#L119-L155","documentation":"Deno.cron accepts either (name, schedule, handler) or (name, schedule, options, handler). When the third argument is a function, the fourth argument must be absent; supplying both counts as two handlers and throws.","triggerScenarios":"Deno.cron('n', '* * * * *', fn, fn2) — any fourth argument alongside a function third argument.","commonSituations":"Copy-paste from an older or imagined API with a completion callback; merging two code paths that each supplied a handler.","solutions":["Delete the extra handler argument.","If options (backoffSchedule, signal) are needed, make the third argument the options object and the fourth the single handler."],"exampleFix":"// before\nDeno.cron('n', '* * * * *', runA, runB);\n// after\nDeno.cron('n', '* * * * *', runA);","handlingStrategy":"validation","validationCode":"if (typeof handlerOrOptions1 === 'function' && handler2 !== undefined) {\n  throw new Error('pass exactly one handler');\n}\nDeno.cron(name, schedule, handlerOrOptions1, handler2);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use one of the two supported shapes only: (name, schedule, handler) or (name, schedule, options, handler).","Do not add completion callbacks — Deno.cron has none."],"tags":["cron","scheduling","validation","api-signature"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}