Repository navigation
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/cloudflare
SDK Version
10.26.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Repository: https://github.com/Jiralite/sentry-cloudflare-env-reproduction
There is a very suspicious pull request, #18064, that seems responsible for this as reverting that definition in 10.26.0 correctly infers env (this means versions 10.23.0 onwards breaks the types).
Steps to Reproduce
- Run TypeScript
Expected Result
env is inferred.
Actual Result
source/index.ts:7:44 - error TS18046: 'env' is of type 'unknown'.
7 export default withSentry((env) => ({ dsn: env.SENTRY_DATA_SOURCE_NAME, sendDefaultPii: true }), {
~~~
source/index.ts:8:2 - error TS2322: Type '(_: Request<unknown, IncomingRequestCfProperties<unknown>>, env: Env) => Response' is not assignable to type 'ExportedHandlerFetchHandler<unknown, unknown>'.
Types of parameters 'env' and 'env' are incompatible.
Type 'unknown' is not assignable to type 'Env'.
8 fetch(_, env) {
~~~~~
node_modules/.pnpm/@cloudflare+workers-types@4.20251121.0/node_modules/@cloudflare/workers-types/2023-07-01/index.d.ts:520:3
520 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
~~~~~
The expected type comes from property 'fetch' which is declared here on type 'ExportedHandler<unknown, unknown, unknown>'
Found 2 errors in the same file, starting at: source/index.ts:7
Additional Context
No response
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear commentedon Nov 23, 2025
JS-1202
JPeer264 commentedon Nov 24, 2025
Hey thanks for the issue. You're right, this definitely breaks the types and was not intentional. I'll get a fix out ASAP.
JPeer264 commentedon Nov 24, 2025
Small update, since the type generics had to change drastically in #18302, we figured it would be a breaking change. So this will land in v11.
As a workaround you can explicitly add the
Envtype in the options:matixlol commentedon Jan 5, 2026
9 remaining items
JPeer264 commentedon Mar 20, 2026
@Jiralite could you try if this type issue is now gone with v10.45.0?
Jiralite commentedon Mar 20, 2026
Hi @JPeer264, this still fails but with a different error. I updated the reproduction repository and added a CI to also reproduce: https://github.com/Jiralite/sentry-cloudflare-env-reproduction/actions/runs/23339011959/job/67887800483
Doing this is still fine, however:
JPeer264 commentedon Mar 20, 2026
Alright I see, you are using
Envfrom your own interface. This will only be fixed with v11 (I keep this issue now open until this is then also fixed for manual types).This can be fixed if you go the Cloudflare way of generating the types: Jiralite/sentry-cloudflare-env-reproduction@0d9976e
The important part is inside the generated
worker-configuration.d.ts, which comes from thewrangler.toml(generated viapnpm generate-types):fix(cloudflare): Restore env type inference for options callbacks (ge…