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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first.
<!-- prettier-ignore-end -->

## Unreleased

### Fixes

- Honor `shutdownTimeout` on iOS ([#6749](https://github.com/getsentry/sentry-react-native/pull/6749))

## 8.27.0

> [!WARNING]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions packages/core/ios/RNSentryStart.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading