Skip to content

Fix type error when using app.use(cf()) from @astrojs/cloudflare/hono - #17594

Merged
matthewp merged 1 commit into
mainfrom
triagebot/fix-17593
Aug 4, 2026
Merged

matthewp merged 1 commit into
mainfrom
triagebot/fix-17593

Conversation

@astrobot-houston

Copy link
Copy Markdown
Contributor

Changes

  • app.use(cf()) from @astrojs/cloudflare/hono now type-checks correctly in projects that use wrangler types. Previously, HonoCloudflareContextLike declared executionCtx: ExecutionContext, binding it to the global ExecutionContext type. When wrangler types generates worker-configuration.d.ts, that global gains required members (tracing, exports) that Hono's own ExecutionContext doesn't have, making the handler contravariant-incompatible with MiddlewareHandler.
  • Replaces executionCtx: ExecutionContext with an inline structural type listing only the three members actually consumed downstream (waitUntil, passThroughOnException, props). This matches the approach astro/hono already uses for its duck-typed context, and the narrowed type remains assignable to internal callers (cfFetch, createLocals) without any casts.

Testing

  • No new automated test — the mismatch only surfaces when the user's wrangler types-generated ExecutionContext global is in scope, which the package's own test compilation doesn't exercise (it compiles against @cloudflare/workers-types, whose ExecutionContext has fewer/optional members). The fix was verified against the reporter's repro at https://github.com/iseraph-dev/repro-astro-cf-hono-types, where astro check goes from 1 error to 0.

Docs

  • No docs change needed — this is a type-only fix with no behavior or API surface change.

Closes #17593

…e to avoid wrangler-generated ExecutionContext mismatch (#17593)
@astrobot-houston astrobot-houston added the fix verified Reporter confirmed the triage bot fix works label Aug 4, 2026
@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7018366

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 42 packages
Name Type
@astrojs/cloudflare Patch
@test/astro-cloudflare-node-prerender-mdx Patch
@test/astro-cloudflare Patch
@test/astro-cloudflare-allowed-hosts Patch
@test/astro-cloudflare-astro-dev-platform Patch
@test/astro-cloudflare-astro-env Patch
@test/astro-cloudflare-binding-image-cache Patch
@test/astro-cloudflare-binding-image-service Patch
@test/astro-cloudflare-cache-provider-wait-until Patch
@test/astro-cloudflare-cache-provider Patch
@test/astro-cloudflare-client-address Patch
@test/astro-cloudflare-compile-custom-image-service Patch
@test/astro-cloudflare-compile-image-service Patch
@test/astro-cloudflare-custom-entryfile Patch
@test/astro-cloudflare-custom-image-service Patch
@test/astro-cloudflare-dev-image-endpoint Patch
@test/astro-cloudflare-external-image-service Patch
@test/astro-cloudflare-external-redirects Patch
@test/astro-cloudflare-internal-redirects Patch
@test/astro-cloudflare-no-output Patch
@test/astro-cloudflare-prerender-node-env Patch
@test/astro-cloudflare-prerender-queue-consumers Patch
@test/astro-cloudflare-prerender-styles Patch
@test/astro-cloudflare-prerenderer-errors Patch
@test/astro-cloudflare-prerenderer-render-error Patch
@test/routing-priority-cloudflare Patch
@test/cf-server-entry Patch
@test/astro-cloudflare-server-island-prerender-framework Patch
@test/astro-cloudflare-sessions Patch
@test/astro-cloudflare-sql-import Patch
@test/cf-ssr-deps Patch
@test/astro-cloudflare-static Patch
@test/astro-cloudflare-svelte-rune-deps Patch
@test/astro-cloudflare-top-level-return Patch
@test/cf-user-optimize-deps Patch
@test/astro-cloudflare-vite-plugin Patch
@test/astro-cloudflare-with-base Patch
@test/astro-cloudflare-with-react Patch
@test/astro-cloudflare-with-solid-js Patch
@test/astro-cloudflare-with-svelte Patch
@test/astro-cloudflare-with-vue Patch
@test/astro-cloudflare-wrangler-preview-platform Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label Aug 4, 2026
@matthewp
matthewp merged commit 2b8915a into main Aug 4, 2026
26 checks passed
@matthewp
matthewp deleted the triagebot/fix-17593 branch August 4, 2026 23:15
@astrobot-houston astrobot-houston mentioned this pull request Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix verified Reporter confirmed the triage bot fix works pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

app.use(cf()) from @astrojs/cloudflare/hono does not type-check

2 participants