feat(cloudflare): Add nodejs_compat entrypoint#21881
Conversation
30afc69 to
0fcde51
Compare
0fcde51 to
a9079a0
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a9079a0. Configure here.
| "require": { | ||
| "types": "./build/types/nodejs_compat/index.d.ts", | ||
| "default": "./build/cjs/nodejs_compat/index.js" | ||
| } |
There was a problem hiding this comment.
Missing E2E for entrypoint
Low Severity
This feat PR adds the public @sentry/cloudflare/nodejs_compat export but does not include an integration or E2E test that imports that subpath under Wrangler with nodejs_compat enabled, so broken export or bundle paths could ship unnoticed.
Additional Locations (1)
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit a9079a0. Configure here.
| "types": "./build/types/nodejs_compat/index.d.ts", | ||
| "default": "./build/esm/nodejs_compat/index.js" | ||
| }, | ||
| "require": { | ||
| "types": "./build/types/nodejs_compat/index.d.ts", | ||
| "default": "./build/cjs/nodejs_compat/index.js" | ||
| } |
There was a problem hiding this comment.
Bug: The typesVersions field in package.json is missing an entry for the new ./nodejs_compat export, which can cause type issues for older TypeScript versions.
Severity: MEDIUM
Suggested Fix
Update the typesVersions field in packages/cloudflare/package.json to include a mapping for the new ./nodejs_compat entrypoint, pointing to its down-leveled type definition file. Specifically, add "build/types/nodejs_compat/index.d.ts": ["build/types-ts3.8/nodejs_compat/index.d.ts"] under the "<5.0" key.
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: packages/cloudflare/package.json#L42-L48
Potential issue: The new `./nodejs_compat` entrypoint in `@sentry/cloudflare` lacks a
corresponding entry in the `typesVersions` field of `package.json`. While users on
TypeScript 5.0+ will get correct types via the `exports` field, users on older
TypeScript versions (< 5.0) will not receive the down-leveled types. This can lead to
type compatibility errors for those users when they import from
`@sentry/cloudflare/nodejs_compat`. Other multi-entrypoint packages in the repository,
like `@sentry/hono`, correctly map all entrypoints in `typesVersions`, establishing a
precedent that was not followed here.
Did we get this right? 👍 / 👎 to inform future reviews.
| "default": "./build/cjs/request.js" | ||
| } | ||
| }, | ||
| "./nodejs_compat": { |
There was a problem hiding this comment.
That would be an option. This is at least getting rid of the _ which I'm not a big fan of



This adds a new
/nodejs_compatexport, which will be used for all features which requires thenodejs_compatcompatibility flag in wrangler. In v11 this will all be merged into the default entrypoint@sentry/cloudflare. But currently in v10 we suggested to usenodejs_als, which is way to little featues and it would simply throw on startup if we wouldn't have a different entrypoint.It will have everything the normal entrypoint has, so it is easier to switch to this entrypoint by just using doing the following:
The name of the entrypoint (
nodejs_compat) is not final - so if there are better suggestions, please go ahead