Skip to content
Merged
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
3 changes: 3 additions & 0 deletions packages/profiling-node/scripts/prune-profiler-binaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const NODE_TO_ABI = {
18: '108',
20: '115',
22: '127',
24: '134',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The NODE_TO_ABI mapping for Node.js v24 is incorrect, using '134' instead of the stable '137' ABI version.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The NODE_TO_ABI mapping at line 66 incorrectly hardcodes the ABI version for Node.js v24 as '134'. The actual stable release of Node.js 24.0.0 uses ABI version '137'. This discrepancy causes the prune() function to incorrectly filter binaries, leading to the deletion of correct profiler binaries (those with ABI 137) or failure to retain them. Consequently, the application will lack a compatible profiler binary at runtime, resulting in functional failures when attempting to load the native module.

💡 Suggested Fix

Update the NODE_TO_ABI mapping in packages/profiling-node/scripts/prune-profiler-binaries.js to set the ABI for Node.js v24 to '137' instead of '134'.

🤖 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/profiling-node/scripts/prune-profiler-binaries.js#L66

Potential issue: The `NODE_TO_ABI` mapping at line 66 incorrectly hardcodes the ABI
version for Node.js v24 as '134'. The actual stable release of Node.js 24.0.0 uses ABI
version '137'. This discrepancy causes the `prune()` function to incorrectly filter
binaries, leading to the deletion of correct profiler binaries (those with ABI 137) or
failure to retain them. Consequently, the application will lack a compatible profiler
binary at runtime, resulting in functional failures when attempting to load the native
module.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 6493649

};

if (NODE) {
Expand All @@ -76,6 +77,8 @@ if (NODE) {
NODE = NODE_TO_ABI['20'];
} else if (NODE.startsWith('22')) {
NODE = NODE_TO_ABI['22'];
} else if (NODE.startsWith('24')) {
NODE = NODE_TO_ABI['24'];
} else {
ARGV_ERRORS.push(
`❌ Sentry: Invalid node version passed as argument, please make sure --target_node is a valid major node version. Supported versions are ${Object.keys(
Expand Down
24 changes: 24 additions & 0 deletions packages/profiling-node/test/prune-profiler-binaries.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { spawnSync } from 'node:child_process';
import * as os from 'node:os';
import * as path from 'node:path';
import { describe, expect, it } from 'vitest';

describe('prune-profiler-binaries', () => {
it('should check if the node version is valid', () => {
const currentNode = process.version.split('v')[1];
const result = spawnSync(
'node',
[
path.join(__dirname, '../scripts/prune-profiler-binaries.js'),
'--target_platform=linux',
'--target_arch=x64',
'--target_stdlib=glibc',
`--target_dir_path=${os.tmpdir()}`,
`--target_node=${currentNode}`,
],
{ encoding: 'utf8' },
);

expect(result.stdout).not.toContain('Invalid node version passed as argument');
});
});