toucan-js
toucan-js copied to clipboard
scheduled waitUntil() don't report anything (maybe to typo in the README)
From the README, passing a function to context.waitUntil
don't seem to work.
export default {
async scheduled(controller: Controller, env: Env, context: Context) {
//...
context.waitUntil(async () => {
try {
// Your code
} catch (err) {
sentry.captureException(err);
}
});
},
}
From Cloudflare Documentation / ScheduledEvent / Syntax: Module Worker, the function passed to context.waitUntil
must be called
export default {
async scheduled(event, env, ctx) {
ctx.waitUntil(doSomeTaskOnASchedule());
},
};
so the code that works:
export default {
async scheduled(controller: Controller, env: Env, context: Context) {
//...
context.waitUntil((async () => {
try {
// Your code
} catch (err) {
sentry.captureException(err);
}
})());
},
}
- module (.mjs)
- wrangler 2.1.6
- node: v18.9.0
- OS: ArchLinux