Repository navigation
Fix type error when using app.use(cf()) from @astrojs/cloudflare/hono - #17594
Merged
Merged
Conversation
…e to avoid wrangler-generated ExecutionContext mismatch (#17593)
🦋 Changeset detectedLatest commit: 7018366 The changes in this PR will be included in the next version bump. This PR includes changesets to release 42 packages
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 |
matthewp
approved these changes
Aug 4, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
app.use(cf())from@astrojs/cloudflare/hononow type-checks correctly in projects that usewrangler types. Previously,HonoCloudflareContextLikedeclaredexecutionCtx: ExecutionContext, binding it to the globalExecutionContexttype. Whenwrangler typesgeneratesworker-configuration.d.ts, that global gains required members (tracing,exports) that Hono's ownExecutionContextdoesn't have, making the handler contravariant-incompatible withMiddlewareHandler.executionCtx: ExecutionContextwith an inline structural type listing only the three members actually consumed downstream (waitUntil,passThroughOnException,props). This matches the approachastro/honoalready uses for its duck-typed context, and the narrowed type remains assignable to internal callers (cfFetch,createLocals) without any casts.Testing
wrangler types-generatedExecutionContextglobal is in scope, which the package's own test compilation doesn't exercise (it compiles against@cloudflare/workers-types, whoseExecutionContexthas fewer/optional members). The fix was verified against the reporter's repro at https://github.com/iseraph-dev/repro-astro-cf-hono-types, whereastro checkgoes from 1 error to 0.Docs
Closes #17593