PurpleLemons
PurpleLemons
CDCloudflare Developers
Created by PurpleLemons on 10/21/2024 in #workers-help
Using `ctx.waitUntil()` in SvelteKit environment
Hello, I am writing caching logic for a service on my SvelteKit app and I would like to be able to use the waitUntil() method to run post-lookup operations after sending the client a response. after debugging an error I was getting, i found that ctx itself was not being passed in the request object at all. my +server.ts code looks something like this:
export const GET = async (request) => {
const { ctx, env } = request.platform || {};
if (!ctx) {
console.error("[DEBUG] Missing Cloudflare context");
} else if (!env) {
console.error("[DEBUG] Missing Cloudflare environment");
}
}
export const GET = async (request) => {
const { ctx, env } = request.platform || {};
if (!ctx) {
console.error("[DEBUG] Missing Cloudflare context");
} else if (!env) {
console.error("[DEBUG] Missing Cloudflare environment");
}
}
$ wrangler tail
...
(error) [DEBUG] Missing Cloudflare context
$ wrangler tail
...
(error) [DEBUG] Missing Cloudflare context
can anyone help? i can't find any documentation about this from either the sveltekit or CF docs
1 replies