Closed shonubijerry closed 3 months ago
Hey @shonubijerry you can export crons and other properties like this
export default {
fetch: app.fetch,
scheduled: async (batch, env) => {},
}
I will add this piece to the docs Thanks for reporting
@G4brym that did it. Thanks
I am trying to migrate from
@cloudflare/itty-router-openapi
v1.1.1With
chanfana
v2.0.2 I noticed that the worker main entry file declared inwrangler.toml
now uses the exported router module directly rather than the usual cloudflare module worker style where I can exportfetch
,scheduled
,queue
etc.How do I add a cron schedule to a chanfana powered API?
I have tried changing the worker entry file to module worker file in
wrangler.toml
, and implement the chanfana router within thefetch
scope. However, if I try to request an endpoint, the code breaks with below error.[ERROR] A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
And I get below as response.
Error: The script will never generate a response. at async Object.fetch (file:///.../node_modules/miniflare/dist/src/workers/core/entry.worker.js:1023:22)
The logs does not show any meaningful message. Am I missing something?
Here is a repo that replicates the issue chanfana-api