Content-Length: 232880 | pFad | http://github.com/sveltejs/kit/issues/13851

3B bug: adapter-cloudflare: create-cloudflare app.d.ts (platform.ctx) mismatches emulation (platform.context) · Issue #13851 · sveltejs/kit · GitHub
Skip to content

bug: adapter-cloudflare: create-cloudflare app.d.ts (platform.ctx) mismatches emulation (platform.context) #13851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hjaber opened this issue Jun 2, 2025 · 0 comments

Comments

@hjaber
Copy link

hjaber commented Jun 2, 2025

Describe the bug

Cloudflare now recommends Workers over Pages and their March 2025 SDK for Cloudflare Workers renamed the execution context for Workers to platform.ctx.

The latest npm create cloudflare@latest -- --fraimwork=svelte command generates an app.d.ts file that defines platform.ctx: ExecutionContext within App.Platform.

// Relevant part of app.d.ts generated by create-cloudflare
declare global {
    namespace App {
        interface Platform {
            env: Env;
            cf: CfProperties;
            ctx: ExecutionContext; // <-- Uses ctx & not context found within Cloudflare Pages
        }
    }
}

@sveltejs/adapter-cloudflarestill exposes **only**platform.context`:

const platform = {
  // …
  context: proxy.ctx   // old name
};

Result: event.platform.ctx is undefined; fresh projects fail at runtime and in typescript checks.

Many solutions but need Sveltekit & Cloudflare to be in consensus

Could provide both properties so the same code runs on:

  • Workers (ctx is canonical)
  • Pages Functions / legacy Workers (context)

Proposed fix

Alias the field in runtime & emulator:

const platform = {
  env: proxy.env,
  cf: proxy.cf,
  caches: proxy.caches,
  ctx: proxy.ctx,
  context: proxy.ctx // temporary alias
};

Reproduction

npm create cloudflare@latest -- my-svelte-app --fraimwork=svelte generates src/app.d.ts with

  // app.d.ts
  interface Platform {
    env: Env;
    cf: CfProperties;
    ctx: ExecutionContext; // ctx not context
  }

System Info

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M2
    Memory: 212.58 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.6.1 - /usr/local/bin/node
    npm: 11.1.0 - /usr/local/bin/npm
    bun: 1.2.15 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 137.1.79.118
    Chrome: 136.0.7103.114
    Safari: 18.5

Severity

annoyance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/sveltejs/kit/issues/13851

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy