Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { D1Database } from '@cloudflare/workers-types';
import { PrismaD1 } from '@prisma/adapter-d1';
import * as Sentry from '@sentry/cloudflare/nodejs_compat';
import * as Sentry from '@sentry/cloudflare';
import { PrismaClient } from './generated';

interface Env {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function envelopeItem(envelope: Envelope): Record<string, unknown> {
return envelope[1][0]![1] as Record<string, unknown>;
}

it('captures a transaction with Prisma spans for a D1 query via the @sentry/cloudflare/nodejs_compat prismaIntegration', async ({
it('captures a transaction with Prisma spans for a D1 query via the @sentry/cloudflare prismaIntegration', async ({
signal,
}) => {
const runner = createRunner(__dirname)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/cloudflare/nodejs_compat';
import * as Sentry from '@sentry/cloudflare';
import { generateText } from 'ai';
import { MockLanguageModelV3 } from 'ai/test';

Expand Down
5 changes: 0 additions & 5 deletions packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
"import": "./build/esm/prod/request.js",
"require": "./build/cjs/prod/request.js"
},
"./nodejs_compat": {
"types": "./build/types/nodejs_compat/index.d.ts",
"import": "./build/esm/prod/nodejs_compat/index.js",
"require": "./build/cjs/prod/nodejs_compat/index.js"
},
"./vite": {
"types": "./build/types/vite/index.d.ts",
"import": "./build/esm/prod/vite/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollu

export default makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/index.ts', 'src/nodejs_compat/index.ts', 'src/vite/index.ts'],
entrypoints: ['src/index.ts', 'src/vite/index.ts'],
}),
{ splitDevProd: true },
);
1 change: 1 addition & 0 deletions packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export { httpServerIntegration } from './integrations/httpServer';
export { fetchIntegration } from './integrations/fetch';
export { spotlightIntegration } from './integrations/spotlight';
export { vercelAIIntegration } from './integrations/tracing/vercelai';
export { prismaIntegration } from '@sentry/server-utils';

// eslint-disable-next-line typescript/no-deprecated
export { instrumentD1WithSentry } from './instrumentations/worker/instrumentD1';
Expand Down
25 changes: 6 additions & 19 deletions packages/cloudflare/src/integrations/tracing/vercelai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,18 @@
*/

import type { IntegrationFn } from '@sentry/core';
import { addVercelAiProcessors, defineIntegration } from '@sentry/core';

const INTEGRATION_NAME = 'VercelAI';

interface VercelAiOptions {
/**
* Enable or disable truncation of recorded input messages.
* Defaults to `true`.
*/
enableTruncation?: boolean;

// `recordInputs`/`recordOutputs` are intentionally omitted: this entrypoint only post-processes
// spans the AI SDK already emitted, so it cannot decide whether inputs/outputs are recorded.
// Control this per call via `experimental_telemetry.recordInputs`/`recordOutputs`, or use the
// `@sentry/cloudflare/nodejs_compat` entrypoint for integration-level control on ai >= 7.
}
import { addVercelAiProcessors, defineIntegration, extendIntegration } from '@sentry/core';
import { vercelAiIntegration, type VercelAiOptions } from '@sentry/server-utils';

const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
return {
name: INTEGRATION_NAME,
const inner = vercelAiIntegration(options);

return extendIntegration(inner, {
options,
setup(client) {
addVercelAiProcessors(client);
},
};
});
Comment on lines +13 to +23

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: Importing vercelAIIntegration from the main entrypoint will cause a startup crash in Cloudflare Workers environments that do not have the nodejs_compat flag enabled.
Severity: HIGH

Suggested Fix

Revert the change that exports vercelAIIntegration from the main entrypoint (packages/cloudflare/src/index.ts). This integration and its Node.js-specific dependencies should be isolated in a separate entrypoint, such as the previously used @sentry/cloudflare/nodejs_compat, to prevent breaking users on runtimes without Node.js compatibility.

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/src/integrations/tracing/vercelai.ts#L13-L23

Potential issue: The `vercelAIIntegration` is now exported from the main
`@sentry/cloudflare` package entrypoint. This integration depends on
`@sentry/server-utils`, which imports the Node.js-specific module
`node:diagnostics_channel` at the top level. Consequently, any user attempting to import
`vercelAIIntegration` in a Cloudflare Worker environment without the `nodejs_compat`
compatibility flag will experience a startup failure. The worker will fail to load
because it cannot resolve the `node:` module, which is a known constraint for certain
runtimes like Shopify Oxygen. This change violates an explicit architectural rule
designed to keep the main package entrypoint free of Node.js dependencies.

Also affects:

  • packages/cloudflare/src/index.ts:132

Did we get this right? 👍 / 👎 to inform future reviews.

}) satisfies IntegrationFn;

/**
Expand Down
3 changes: 0 additions & 3 deletions packages/cloudflare/src/nodejs_compat/index.ts

This file was deleted.

Loading
Loading