Skip to content

Commit

Permalink
ref(profiling-node): Add warning when using non-LTS node (#12211)
Browse files Browse the repository at this point in the history
resolves #11777
  • Loading branch information
AbhiPrasad committed May 27, 2024
1 parent c2b9079 commit 1f8f1b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/profiling-node/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { IntegrationFn, Span } from '@sentry/types';
import { logger } from '@sentry/utils';

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

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

/** Exported only for tests. */
export const _nodeProfilingIntegration = (() => {
if (DEBUG_BUILD && ![16, 18, 20, 22].includes(NODE_MAJOR)) {
logger.warn(
`[Profiling] You are using a Node.js version that does not have prebuilt binaries (${NODE_VERSION}).`,
'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22.',
'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',
);
}

return {
name: 'ProfilingIntegration',
setup(client: NodeClient) {
Expand Down
4 changes: 4 additions & 0 deletions packages/profiling-node/src/nodeVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { parseSemver } from '@sentry/utils';

export const NODE_VERSION = parseSemver(process.versions.node) as { major: number; minor: number; patch: number };
export const NODE_MAJOR = NODE_VERSION.major;

0 comments on commit 1f8f1b8

Please sign in to comment.