Skip to content

Commit f73db5d

Browse files
authored
Merge branch 'antonis/oxlint' into antonis/oxfmt
2 parents ba48bdb + 089e0c9 commit f73db5d

3 files changed

Lines changed: 34 additions & 8 deletions

File tree

.github/workflows/e2e-v2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ jobs:
205205
MATCH_USERNAME: ${{ secrets.MATCH_USERNAME }}
206206
- name: Collect apps metrics
207207
if: ${{ steps.platform-check.outputs.skip != 'true' }}
208-
uses: getsentry/action-app-sdk-overhead-metrics@ecce2e2718b6d97ad62220fca05627900b061ed5
208+
uses: getsentry/action-app-sdk-overhead-metrics@44fb5489ac4ac252c87d84811972dc93a1e490b8
209209
with:
210210
name: ${{ matrix.name }} (${{ matrix.rn-architecture }})
211211
config: ./performance-tests/metrics-${{ matrix.platform }}.yml

packages/core/src/js/sdk.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ export function init(passedOptions: ReactNativeOptions): void {
143143
initialScope: safeFactory(userOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),
144144
};
145145

146-
if (!('autoInitializeNativeSdk' in userOptions) && RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {
147-
// Options file is present, native SDK is expected to be initialized
146+
if (!('autoInitializeNativeSdk' in userOptions) && RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ && !__DEV__) {
147+
// Options file is present in a release build, native SDK is expected to be initialized
148148
// before JS from the native app entry point (e.g. AppDelegate, MainApplication).
149+
// In dev builds, we always re-initialize from JS to set up the native log bridge
150+
// and provide runtime values (devServerUrl, defaultSidecarUrl, etc.).
149151
// oxlint-disable-next-line eslint(no-console)
150152
console.info(
151153
'[Sentry] Using options file. Native SDK is expected to be initialized before JS, skipping automatic native initialization from JS.',

packages/core/test/sdk.test.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,34 @@ describe('Tests the SDK functionality', () => {
138138
expect(usedOptions()?.dsn).toBe('https://key@example.io/code');
139139
});
140140

141-
it('initializing with __SENTRY_OPTIONS__ disabled native auto initialization', () => {
142-
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
143-
init({});
144-
expect(usedOptions()?.autoInitializeNativeSdk).toBe(false);
141+
it('does not disable native auto initialization in dev builds even with __SENTRY_OPTIONS__', () => {
142+
// @ts-expect-error __DEV__ is a global
143+
const originalDev = globalThis.__DEV__;
144+
// @ts-expect-error __DEV__ is a global
145+
globalThis.__DEV__ = true;
146+
try {
147+
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
148+
init({});
149+
expect(usedOptions()?.autoInitializeNativeSdk).toBe(true);
150+
} finally {
151+
// @ts-expect-error __DEV__ is a global
152+
globalThis.__DEV__ = originalDev;
153+
}
154+
});
155+
156+
it('disables native auto initialization in release builds with __SENTRY_OPTIONS__', () => {
157+
// @ts-expect-error __DEV__ is a global
158+
const originalDev = globalThis.__DEV__;
159+
// @ts-expect-error __DEV__ is a global
160+
globalThis.__DEV__ = false;
161+
try {
162+
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
163+
init({});
164+
expect(usedOptions()?.autoInitializeNativeSdk).toBe(false);
165+
} finally {
166+
// @ts-expect-error __DEV__ is a global
167+
globalThis.__DEV__ = originalDev;
168+
}
145169
});
146170

147171
it('initializing without __SENTRY_OPTIONS__ enables native auto initialization', () => {
@@ -158,7 +182,7 @@ describe('Tests the SDK functionality', () => {
158182
expect(usedOptions()?.autoInitializeNativeSdk).toBe(true);
159183
});
160184

161-
it('initializing with __SENTRY_OPTIONS__ keeps native auto initialization false if set', () => {
185+
it('respects explicit autoInitializeNativeSdk false even with __SENTRY_OPTIONS__', () => {
162186
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
163187
init({
164188
autoInitializeNativeSdk: false,

0 commit comments

Comments
 (0)