diff --git a/packages/profiling-node/src/integration.ts b/packages/profiling-node/src/integration.ts index 17ce6f702639..9b4fd1601420 100644 --- a/packages/profiling-node/src/integration.ts +++ b/packages/profiling-node/src/integration.ts @@ -15,7 +15,7 @@ import { import type { NodeClient, NodeOptions } from '@sentry/node'; import { CpuProfilerBindings, ProfileFormat, type RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler'; import { DEBUG_BUILD } from './debug-build'; -import { NODE_MAJOR, NODE_VERSION } from './nodeVersion'; +import { NODE_MAJOR } from './nodeVersion'; import { MAX_PROFILE_DURATION_MS, maybeProfileSpan, stopSpanProfile } from './spanProfileUtils'; import { addProfilesToEnvelope, @@ -634,7 +634,7 @@ export const _nodeProfilingIntegration = ((): ProfilingIntegration = consoleSandbox(() => { // eslint-disable-next-line no-console console.warn( - `[Sentry Profiling] You are using a Node.js version that does not have prebuilt binaries (${NODE_VERSION}).`, + `[Sentry Profiling] You are using a Node.js version that does not have prebuilt binaries (${NODE_MAJOR}).`, 'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22, 24.', 'To use the @sentry/profiling-node package with this version of Node.js, you will need to compile the native addon from source.', 'See: https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node#building-the-package-from-source', diff --git a/packages/profiling-node/test/integration.test.ts b/packages/profiling-node/test/integration.test.ts index a0ff14d4602e..41f195b8b3c6 100644 --- a/packages/profiling-node/test/integration.test.ts +++ b/packages/profiling-node/test/integration.test.ts @@ -5,6 +5,7 @@ import type { NodeClientOptions } from '@sentry/node/build/types/types'; import { CpuProfilerBindings } from '@sentry-internal/node-cpu-profiler'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { _nodeProfilingIntegration } from '../src/integration'; +import { NODE_VERSION } from '../src/nodeVersion'; function makeLegacySpanProfilingClient(): [Sentry.NodeClient, Transport] { const integration = _nodeProfilingIntegration(); @@ -984,6 +985,16 @@ describe('ProfilingIntegration', () => { }); }); +describe('NODE_VERSION', () => { + it('is a plain object without a custom toString', () => { + // NODE_VERSION is a SemVer object from parseSemver — it has no custom toString(). + // Code should never interpolate it directly in a template literal. + // Use process.versions.node or format the components manually instead. + expect(`${NODE_VERSION}`).toBe('[object Object]'); + expect(`${NODE_VERSION.major}.${NODE_VERSION.minor}.${NODE_VERSION.patch}`).toMatch(/^\d+\.\d+\.\d+$/); + }); +}); + describe('Legacy vs Current API compat', () => { describe('legacy', () => { describe('span profiling', () => {