© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•16mo ago
PurpleLemons

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()
waitUntil()
method to run post-lookup operations after sending the client a response. after debugging an error I was getting, i found that
ctx
ctx
itself was not being passed in the request object at all.
my
+server.ts
+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
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

calling ctx.waitUntil multiple times
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
4mo ago
Does ctx.waitUntil work with hyperdrive?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
Suddenly all our ctx.waitUntil workers are failing?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
10mo ago
Delay ctx.waitUntil() until fetch() has completed or canceled
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago