docs(cloudflare): Change onboarding script for Cloudflare Workers#105640
docs(cloudflare): Change onboarding script for Cloudflare Workers#105640
Conversation
|
|
||
| export default Sentry.withSentry( | ||
| env => ({ | ||
| (env: Env) => ({ |
There was a problem hiding this comment.
Bug: The Cloudflare Workers onboarding guide provides a code snippet using the Env type but omits the required wrangler types command to generate it, causing a TypeScript error.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The onboarding documentation for Cloudflare Workers provides code snippets that use the Env type, for example in (env: Env) => and satisfies ExportedHandler<Env>. However, the Env type is not globally available and must be generated by running the wrangler types command. The current onboarding instructions do not mention this prerequisite step. Consequently, users who copy and paste the provided code into their TypeScript project will encounter a compilation error: "Cannot find name 'Env'". This blocks them from successfully completing the SDK setup as documented.
💡 Suggested Fix
Update the Cloudflare Workers onboarding documentation to include a step instructing the user to run npx wrangler types before they are prompted to use the code snippet. This will ensure the Env type definition is generated and available to the TypeScript compiler.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: static/app/gettingStartedDocs/node-cloudflare-workers/onboarding.tsx#L28
Potential issue: The onboarding documentation for Cloudflare Workers provides code
snippets that use the `Env` type, for example in `(env: Env) =>` and `satisfies
ExportedHandler<Env>`. However, the `Env` type is not globally available and must be
generated by running the `wrangler types` command. The current onboarding instructions
do not mention this prerequisite step. Consequently, users who copy and paste the
provided code into their TypeScript project will encounter a compilation error: "Cannot
find name 'Env'". This blocks them from successfully completing the SDK setup as
documented.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8175928
This adds the workaround until v11 is out. At the moment we have to explicitly set
(env: Env) => ...in order to make the types work. This can be reverted (no must) when following is merged and released: getsentry/sentry-javascript#18302reference: getsentry/sentry-javascript#18294 (comment)