Is it possible for us to use scheduler handler and waitUntil function inside astro endpoints? I see the types available in ctx.locals.runtime but then the value is undefined
https://developers.cloudflare.com/workers/configuration/cron-triggers/
7 messages · Page 1 of 1 (latest)
Is it possible for us to use scheduler handler and waitUntil function inside astro endpoints? I see the types available in ctx.locals.runtime but then the value is undefined
https://developers.cloudflare.com/workers/configuration/cron-triggers/
Hi @vital helm. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the knowledge sources provided, there is no specific information about using the Cloudflare scheduler handler and waitUntil function inside Astro endpoints.
Astro endpoints allow you to create custom endpoints to serve any kind of data, which can be used to generate images, expose an RSS document, or build a full API for your site. In statically-generated sites, these custom endpoints are called at build time to produce static files. If you opt in to SSR mode, custom endpoints turn into live server endpoints that are called on request (source (https://docs.astro.build/en/guides/endpoints#_top)).
However, there is a discussion about the compatibility of Cloudflare Pages Environment Variables with Astro, and it's mentioned that there are two worlds existing in parallel with the Cloudflare deployments. One is building an API route the Astro way, and the other is using native Cloudflare functions. The contributor mentioned working on a PR to enable access to the Cloudflare runtime from the Astro world (source (https://github.com/withastro/astro/issues/5170)).
waitUntil function with Astro, you may need to refer to the official Astro and Cloudflare documentation or community forums.@vital helm kapa.ai is still learning and improving, please let us know how it did by reacting below
@little bear is there any updates on this? Can we trigger the cloudflare scheduled cron trigger locally when using the astro adapter and workerEntryPoint configuration?
Let me check the knowledge base for you again. One moment! :books:
I'm sorry, but the knowledge sources do not provide explicit information about triggering Cloudflare scheduled cron triggers locally when using the Astro Cloudflare adapter and the workerEntryPoint configuration. While the documentation explains how to configure a custom worker entry file and mentions support for additional handlers (such as Durable Objects, Queues, and Scheduled Invocations) via the workerEntryPoint option, it does not detail local development or testing of scheduled cron triggers specifically within Astro's workflow.
The documentation does show how to register handlers in a custom entry file, including a queue handler, but does not mention local invocation or simulation of scheduled (cron) events:
// Example from docs for custom worker entry file
export function createExports(manifest: SSRManifest) {
const app = new App(manifest);
return {
default: {
async fetch(request, env, ctx) {
// ...
return handle(manifest, app, request, env, ctx);
},
async queue(batch, _env) {
// ...
}
} satisfies ExportedHandler<Env>,
MyDurableObject: MyDurableObject,
}
}
Custom worker entry file example
If you need to test scheduled handlers locally, you may need to refer to Cloudflare's own documentation or tools for simulating cron triggers, as this is not covered in the Astro documentation.
workerEntryPoint configuration.