Skip to content

Commit 1f8f1b8

Browse files
authored
ref(profiling-node): Add warning when using non-LTS node (#12211)
resolves #11777
1 parent c2b9079 commit 1f8f1b8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/profiling-node/src/integration.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { IntegrationFn, Span } from '@sentry/types';
55
import { logger } from '@sentry/utils';
66

77
import { DEBUG_BUILD } from './debug-build';
8+
import { NODE_MAJOR, NODE_VERSION } from './nodeVersion';
89
import { MAX_PROFILE_DURATION_MS, maybeProfileSpan, stopSpanProfile } from './spanProfileUtils';
910
import type { Profile, RawThreadCpuProfile } from './types';
1011

@@ -25,6 +26,15 @@ function addToProfileQueue(profile: RawThreadCpuProfile): void {
2526

2627
/** Exported only for tests. */
2728
export const _nodeProfilingIntegration = (() => {
29+
if (DEBUG_BUILD && ![16, 18, 20, 22].includes(NODE_MAJOR)) {
30+
logger.warn(
31+
`[Profiling] You are using a Node.js version that does not have prebuilt binaries (${NODE_VERSION}).`,
32+
'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22.',
33+
'To use the @sentry/profiling-node package with this version of Node.js, you will need to compile the native addon from source.',
34+
'See: https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node#building-the-package-from-source',
35+
);
36+
}
37+
2838
return {
2939
name: 'ProfilingIntegration',
3040
setup(client: NodeClient) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { parseSemver } from '@sentry/utils';
2+
3+
export const NODE_VERSION = parseSemver(process.versions.node) as { major: number; minor: number; patch: number };
4+
export const NODE_MAJOR = NODE_VERSION.major;

0 commit comments

Comments
 (0)