Skip to content

feat(cloudflare): Add nodejs_compat entrypoint#21881

Open
JPeer264 wants to merge 1 commit into
developfrom
jp/add-nodejs-compat-entrypoint
Open

feat(cloudflare): Add nodejs_compat entrypoint#21881
JPeer264 wants to merge 1 commit into
developfrom
jp/add-nodejs-compat-entrypoint

Conversation

@JPeer264

@JPeer264 JPeer264 commented Jul 1, 2026

Copy link
Copy Markdown
Member

This adds a new /nodejs_compat export, which will be used for all features which requires the nodejs_compat compatibility flag in wrangler. In v11 this will all be merged into the default entrypoint @sentry/cloudflare. But currently in v10 we suggested to use nodejs_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:

- import * as Sentry from '@sentry/cloudflare';
+ import * as Sentry from '@sentry/cloudflare/nodejs_compat';

The name of the entrypoint (nodejs_compat) is not final - so if there are better suggestions, please go ahead

@JPeer264 JPeer264 self-assigned this Jul 1, 2026
@JPeer264 JPeer264 force-pushed the jp/add-nodejs-compat-entrypoint branch from 30afc69 to 0fcde51 Compare July 1, 2026 12:14
@JPeer264 JPeer264 force-pushed the jp/add-nodejs-compat-entrypoint branch from 0fcde51 to a9079a0 Compare July 1, 2026 12:15
@JPeer264 JPeer264 marked this pull request as ready for review July 1, 2026 12:18
@JPeer264 JPeer264 requested a review from a team as a code owner July 1, 2026 12:18
@JPeer264 JPeer264 requested review from andreiborza and mydea and removed request for a team July 1, 2026 12:18

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit a9079a0. Configure here.

Comment on lines +42 to +48
"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"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the nodejs_? Just compat?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be an option. This is at least getting rid of the _ which I'm not a big fan of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants