From 3d8743a8ef55c2be61969e85c1c2bba09374e165 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Thu, 17 Sep 2026 15:35:11 +0200 Subject: [PATCH 1/2] fix(ios): Honor shutdownTimeout on iOS JS `shutdownTimeout` (milliseconds) was silently ignored on iOS. Cocoa's dictionary parser only reads `shutdownTimeInterval` (an NSTimeInterval in seconds), so the native default (2s) was always used. Android was already correct via `setShutdownTimeoutMillis`. Map `shutdownTimeout` (ms) to `shutdownTimeInterval` (s) in RNSentryStart, dividing by 1000. Adds Cocoa unit tests for the mapping and the default. Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 6 ++++++ .../RNSentryStartTests.swift | 21 +++++++++++++++++++ packages/core/ios/RNSentryStart.m | 9 ++++++++ 3 files changed, 36 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bd13841cd..2d04bbbc14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ > make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first. +## Unreleased + +### Fixes + +- Honor `shutdownTimeout` on iOS ([#6748](https://github.com/getsentry/sentry-react-native/issues/6748)) + ## 8.27.0 > [!WARNING] diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryStartTests.swift b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryStartTests.swift index 0bcd75dac7..431bc62123 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryStartTests.swift +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryStartTests.swift @@ -245,6 +245,27 @@ final class RNSentryStartTests: XCTestCase { XCTAssertFalse(actualOptions.enableMemoryIntrospection) } + func testShutdownTimeoutMapsMillisecondsToSeconds() throws { + try startFromRN(options: [ + "dsn": "https://abcd@efgh.ingest.sentry.io/123456", + // JS passes milliseconds; Cocoa's shutdownTimeInterval is in seconds + "shutdownTimeout": 5_000 + ]) + + let actualOptions = SentrySDK.internal.options + XCTAssertEqual(actualOptions.shutdownTimeInterval, 5.0) + } + + func testShutdownTimeoutDefault() throws { + try startFromRN(options: [ + "dsn": "https://abcd@efgh.ingest.sentry.io/123456" + ]) + + let actualOptions = SentrySDK.internal.options + // Cocoa's default shutdownTimeInterval is 2 seconds + XCTAssertEqual(actualOptions.shutdownTimeInterval, 2.0) + } + func startFromRN(options: [String: Any]) throws { var error: NSError? RNSentryStart.start(options: options, error: &error) diff --git a/packages/core/ios/RNSentryStart.m b/packages/core/ios/RNSentryStart.m index 2a499a995d..13c1230cab 100644 --- a/packages/core/ios/RNSentryStart.m +++ b/packages/core/ios/RNSentryStart.m @@ -197,6 +197,15 @@ + (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull) } } + // JS `shutdownTimeout` is in milliseconds (matching Android's `setShutdownTimeoutMillis`), + // while Cocoa's `shutdownTimeInterval` is an NSTimeInterval in seconds. The Cocoa dictionary + // parser only reads `shutdownTimeInterval`, so without this mapping the JS option is ignored on + // iOS and the native default is always used. + id shutdownTimeoutValue = [mutableOptions valueForKey:@"shutdownTimeout"]; + if ([shutdownTimeoutValue isKindOfClass:[NSNumber class]]) { + sentryOptions.shutdownTimeInterval = [shutdownTimeoutValue doubleValue] / 1000.0; + } + return sentryOptions; } From 8061d47c5df2a3d85d7970e69ea068aa546da93d Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Thu, 17 Sep 2026 15:37:22 +0200 Subject: [PATCH 2/2] Add PR reference --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d04bbbc14..f40c5c9d44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### Fixes -- Honor `shutdownTimeout` on iOS ([#6748](https://github.com/getsentry/sentry-react-native/issues/6748)) +- Honor `shutdownTimeout` on iOS ([#6749](https://github.com/getsentry/sentry-react-native/pull/6749)) ## 8.27.0