Skip to content

Commit 7b7b4fa

Browse files
antonisclaude
andauthored
fix(profiling): Populate Hermes runtime version on JS profiles (#6817)
The Hermes JS profile payload has always sent an empty `runtime.version` placeholder. Wire it up to the existing `getHermesVersion()` helper so profiles carry the real Hermes version (falling back to `''` when Hermes does not report one, matching the previous behavior). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5f23262 commit 7b7b4fa

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first.
77
<!-- prettier-ignore-end -->
88
9+
## Unreleased
10+
11+
### Fixes
12+
13+
- Populate the Hermes runtime version on JS profiles instead of sending an empty value ([#6817](https://github.com/getsentry/sentry-react-native/pull/6817))
14+
915
## 8.29.0
1016

1117
### Features

‎packages/core/src/js/profiling/utils.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
RawThreadCpuProfile,
1313
} from './types';
1414

15-
import { getDefaultEnvironment } from '../utils/environment';
15+
import { getDefaultEnvironment, getHermesVersion } from '../utils/environment';
1616
import { getDebugMetadata } from './debugid';
1717

1818
/**
@@ -95,7 +95,7 @@ export function enrichCombinedProfileWithEventContext(
9595
event_id: profile_id,
9696
runtime: {
9797
name: 'hermes',
98-
version: '', // TODO: get hermes version
98+
version: getHermesVersion() ?? '',
9999
},
100100
timestamp: profilingStartTimestampNs
101101
? new Date(profilingStartTimestampNs / 1e6).toISOString()

‎packages/core/test/profiling/utils.test.ts‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
enrichAndroidProfileWithEventContext,
1111
enrichCombinedProfileWithEventContext,
1212
} from '../../src/js/profiling/utils';
13-
import { getDefaultEnvironment } from '../../src/js/utils/environment';
13+
import { getDefaultEnvironment, getHermesVersion } from '../../src/js/utils/environment';
1414
import { createMockMinimalValidAndroidProfile, createMockMinimalValidHermesProfileEvent } from './fixtures';
1515

1616
describe('enrichCombinedProfileWithEventContext', () => {
@@ -19,6 +19,29 @@ describe('enrichCombinedProfileWithEventContext', () => {
1919
(getDebugMetadata as jest.Mock).mockReturnValue([]);
2020
});
2121

22+
test('should set the hermes runtime version from getHermesVersion', () => {
23+
// OSS Hermes reports the version it was built against, e.g. `for RN 0.76.0`, not a semver.
24+
(getHermesVersion as jest.Mock).mockReturnValue('for RN 0.76.0');
25+
const profile: CombinedProfileEvent = createMockMinimalValidHermesProfileEvent();
26+
const event = createMockEvent();
27+
28+
const result = enrichCombinedProfileWithEventContext('profile-id', profile, event);
29+
30+
expect(result).not.toBeNull();
31+
expect(result!.runtime).toEqual({ name: 'hermes', version: 'for RN 0.76.0' });
32+
});
33+
34+
test('should fall back to an empty runtime version when the hermes version is unavailable', () => {
35+
(getHermesVersion as jest.Mock).mockReturnValue(undefined);
36+
const profile: CombinedProfileEvent = createMockMinimalValidHermesProfileEvent();
37+
const event = createMockEvent();
38+
39+
const result = enrichCombinedProfileWithEventContext('profile-id', profile, event);
40+
41+
expect(result).not.toBeNull();
42+
expect(result!.runtime).toEqual({ name: 'hermes', version: '' });
43+
});
44+
2245
function createMockEvent(overrides?: Partial<Event>): Event {
2346
return {
2447
event_id: 'test-event-id',

0 commit comments

Comments
 (0)