From 75870b8cdb72cf1a323416b46ef0e8b461aac957 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Tue, 3 Jun 2025 16:30:46 +0200 Subject: [PATCH 1/4] conditionally instrument rr --- packages/node/src/index.ts | 1 + packages/react-router/src/server/sdk.ts | 14 ++++---- packages/react-router/test/server/sdk.test.ts | 36 +++++++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 5a933002bc23..589937b21fd4 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -54,6 +54,7 @@ export { createGetModuleFromFilename } from './utils/module'; export { makeNodeTransport } from './transports'; export { NodeClient } from './sdk/client'; export { cron } from './cron'; +export { NODE_VERSION } from './nodeVersion'; export type { NodeOptions } from './types'; diff --git a/packages/react-router/src/server/sdk.ts b/packages/react-router/src/server/sdk.ts index 55eaf6962a28..110ed8d030cc 100644 --- a/packages/react-router/src/server/sdk.ts +++ b/packages/react-router/src/server/sdk.ts @@ -2,7 +2,7 @@ import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; import type { EventProcessor, Integration } from '@sentry/core'; import { applySdkMetadata, getGlobalScope, logger, setTag } from '@sentry/core'; import type { NodeClient, NodeOptions } from '@sentry/node'; -import { getDefaultIntegrations as getNodeDefaultIntegrations, init as initNodeSdk } from '@sentry/node'; +import { getDefaultIntegrations as getNodeDefaultIntegrations, init as initNodeSdk, NODE_VERSION } from '@sentry/node'; import { DEBUG_BUILD } from '../common/debug-build'; import { SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE } from './instrumentation/util'; import { lowQualityTransactionsFilterIntegration } from './integration/lowQualityTransactionsFilterIntegration'; @@ -13,11 +13,13 @@ import { reactRouterServerIntegration } from './integration/reactRouterServer'; * @param options The options for the SDK. */ export function getDefaultReactRouterServerIntegrations(options: NodeOptions): Integration[] { - return [ - ...getNodeDefaultIntegrations(options), - lowQualityTransactionsFilterIntegration(options), - reactRouterServerIntegration(), - ]; + const integrations = [...getNodeDefaultIntegrations(options), lowQualityTransactionsFilterIntegration(options)]; + + if (NODE_VERSION.major === 20 && NODE_VERSION.minor < 19) { + integrations.push(reactRouterServerIntegration()); + } + + return integrations; } /** diff --git a/packages/react-router/test/server/sdk.test.ts b/packages/react-router/test/server/sdk.test.ts index fdb894299760..dec5e2bd2269 100644 --- a/packages/react-router/test/server/sdk.test.ts +++ b/packages/react-router/test/server/sdk.test.ts @@ -71,5 +71,41 @@ describe('React Router server SDK', () => { expect(filterIntegration).toBeDefined(); }); + + it('adds reactRouterServer integration for Node.js 20.18', () => { + vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 20, minor: 18, patch: 0 }); + + reactRouterInit({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + }); + + expect(nodeInit).toHaveBeenCalledTimes(1); + const initOptions = nodeInit.mock.calls[0]?.[0]; + const defaultIntegrations = initOptions?.defaultIntegrations as Integration[]; + + const reactRouterServerIntegration = defaultIntegrations.find( + integration => integration.name === 'ReactRouterServer', + ); + + expect(reactRouterServerIntegration).toBeDefined(); + }); + + it('does not add reactRouterServer integration for Node.js 20.19', () => { + vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 20, minor: 19, patch: 0 }); + + reactRouterInit({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + }); + + expect(nodeInit).toHaveBeenCalledTimes(1); + const initOptions = nodeInit.mock.calls[0]?.[0]; + const defaultIntegrations = initOptions?.defaultIntegrations as Integration[]; + + const reactRouterServerIntegration = defaultIntegrations.find( + integration => integration.name === 'ReactRouterServer', + ); + + expect(reactRouterServerIntegration).toBeUndefined(); + }); }); }); From 5433c10e44d6b3944a7b2b1cce4d2bc385bb9cfa Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 4 Jun 2025 10:55:48 +0200 Subject: [PATCH 2/4] add missing node exports --- packages/astro/src/index.server.ts | 1 + packages/aws-serverless/src/index.ts | 1 + packages/bun/src/index.ts | 1 + packages/google-cloud-serverless/src/index.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/packages/astro/src/index.server.ts b/packages/astro/src/index.server.ts index 29105cfb4b18..ac222eca825b 100644 --- a/packages/astro/src/index.server.ts +++ b/packages/astro/src/index.server.ts @@ -134,6 +134,7 @@ export { logger, consoleLoggingIntegration, wrapMcpServerWithSentry, + NODE_VERSION, } from '@sentry/node'; export { init } from './server/sdk'; diff --git a/packages/aws-serverless/src/index.ts b/packages/aws-serverless/src/index.ts index 942951c165da..24513a325188 100644 --- a/packages/aws-serverless/src/index.ts +++ b/packages/aws-serverless/src/index.ts @@ -120,6 +120,7 @@ export { logger, consoleLoggingIntegration, wrapMcpServerWithSentry, + NODE_VERSION, } from '@sentry/node'; export { diff --git a/packages/bun/src/index.ts b/packages/bun/src/index.ts index 70104de6d7c3..66cec7c1e136 100644 --- a/packages/bun/src/index.ts +++ b/packages/bun/src/index.ts @@ -139,6 +139,7 @@ export { consoleLoggingIntegration, createSentryWinstonTransport, wrapMcpServerWithSentry, + NODE_VERSION, } from '@sentry/node'; export { diff --git a/packages/google-cloud-serverless/src/index.ts b/packages/google-cloud-serverless/src/index.ts index f5d593312743..f2622e591497 100644 --- a/packages/google-cloud-serverless/src/index.ts +++ b/packages/google-cloud-serverless/src/index.ts @@ -120,6 +120,7 @@ export { logger, consoleLoggingIntegration, wrapMcpServerWithSentry, + NODE_VERSION, } from '@sentry/node'; export { From cda8270d89f5f57a309f46d06c0408b16a8921ab Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 4 Jun 2025 13:31:42 +0200 Subject: [PATCH 3/4] add node 22 support --- packages/react-router/src/server/sdk.ts | 5 ++- packages/react-router/test/server/sdk.test.ts | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/react-router/src/server/sdk.ts b/packages/react-router/src/server/sdk.ts index 110ed8d030cc..07ea80e867ea 100644 --- a/packages/react-router/src/server/sdk.ts +++ b/packages/react-router/src/server/sdk.ts @@ -15,7 +15,10 @@ import { reactRouterServerIntegration } from './integration/reactRouterServer'; export function getDefaultReactRouterServerIntegrations(options: NodeOptions): Integration[] { const integrations = [...getNodeDefaultIntegrations(options), lowQualityTransactionsFilterIntegration(options)]; - if (NODE_VERSION.major === 20 && NODE_VERSION.minor < 19) { + if ( + (NODE_VERSION.major === 20 && NODE_VERSION.minor < 19) || // https://nodejs.org/en/blog/release/v20.19.0 + (NODE_VERSION.major === 22 && NODE_VERSION.minor < 12) // https://nodejs.org/en/blog/release/v22.12.0 + ) { integrations.push(reactRouterServerIntegration()); } diff --git a/packages/react-router/test/server/sdk.test.ts b/packages/react-router/test/server/sdk.test.ts index dec5e2bd2269..861144e3f62b 100644 --- a/packages/react-router/test/server/sdk.test.ts +++ b/packages/react-router/test/server/sdk.test.ts @@ -90,6 +90,24 @@ describe('React Router server SDK', () => { expect(reactRouterServerIntegration).toBeDefined(); }); + it('adds reactRouterServer integration for Node.js 22.11', () => { + vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 22, minor: 11, patch: 0 }); + + reactRouterInit({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + }); + + expect(nodeInit).toHaveBeenCalledTimes(1); + const initOptions = nodeInit.mock.calls[0]?.[0]; + const defaultIntegrations = initOptions?.defaultIntegrations as Integration[]; + + const reactRouterServerIntegration = defaultIntegrations.find( + integration => integration.name === 'ReactRouterServer', + ); + + expect(reactRouterServerIntegration).toBeDefined(); + }); + it('does not add reactRouterServer integration for Node.js 20.19', () => { vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 20, minor: 19, patch: 0 }); @@ -107,5 +125,23 @@ describe('React Router server SDK', () => { expect(reactRouterServerIntegration).toBeUndefined(); }); + + it('does not add reactRouterServer integration for Node.js 22.12', () => { + vi.spyOn(SentryNode, 'NODE_VERSION', 'get').mockReturnValue({ major: 22, minor: 12, patch: 0 }); + + reactRouterInit({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + }); + + expect(nodeInit).toHaveBeenCalledTimes(1); + const initOptions = nodeInit.mock.calls[0]?.[0]; + const defaultIntegrations = initOptions?.defaultIntegrations as Integration[]; + + const reactRouterServerIntegration = defaultIntegrations.find( + integration => integration.name === 'ReactRouterServer', + ); + + expect(reactRouterServerIntegration).toBeUndefined(); + }); }); }); From 2540e600b608c2d66a3d4a86d65df97bca5d7aad Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 4 Jun 2025 14:06:17 +0200 Subject: [PATCH 4/4] no node version export for bun --- .../node-exports-test-app/scripts/consistentExports.ts | 1 + packages/bun/src/index.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts b/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts index 8c3e51b14024..f355654bf6a2 100644 --- a/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts +++ b/dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts @@ -50,6 +50,7 @@ const DEPENDENTS: Dependent[] = [ ignoreExports: [ // not supported in bun: 'NodeClient', + 'NODE_VERSION', 'childProcessIntegration', ], }, diff --git a/packages/bun/src/index.ts b/packages/bun/src/index.ts index 66cec7c1e136..70104de6d7c3 100644 --- a/packages/bun/src/index.ts +++ b/packages/bun/src/index.ts @@ -139,7 +139,6 @@ export { consoleLoggingIntegration, createSentryWinstonTransport, wrapMcpServerWithSentry, - NODE_VERSION, } from '@sentry/node'; export { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy