Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class PluginSessionReplayReactNative: NSObject {
serverZone: serverZone == "EU" ? .EU : .US,
enableRemoteConfig: enableRemoteConfig)
if (autoStart) {
sessionReplay.start()
DispatchQueue.main.async {
self.sessionReplay.start()
}
}
resolve(nil)
}
Expand All @@ -65,15 +67,19 @@ class PluginSessionReplayReactNative: NSObject {
@objc(start:reject:)
func start(_ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
print("start")
sessionReplay.start()
resolve(nil)
DispatchQueue.main.async {
self.sessionReplay.start()
resolve(nil)
}
Comment on lines +70 to +73
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Inconsistent promise resolution pattern: In this method, resolve(nil) is called inside the DispatchQueue.main.async block (line 72), but in the setup() method when autoStart is true (lines 41-43), the resolve(nil) is called outside the async block (line 45).

For consistency, either:

  1. Move resolve(nil) outside the async block here to match setup() (resolves immediately, fire-and-forget pattern)
  2. Or move the resolve(nil) in setup() inside its async block (waits for completion)

The choice depends on whether JavaScript callers need to wait for the operation to complete on the main thread before the promise resolves.

Copilot uses AI. Check for mistakes.
}

@objc(stop:reject:)
func stop(_ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
print("stop")
sessionReplay.stop()
resolve(nil)
DispatchQueue.main.async {
self.sessionReplay.stop()
resolve(nil)
}
Comment on lines +79 to +82
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Inconsistent promise resolution pattern: In this method, resolve(nil) is called inside the DispatchQueue.main.async block (line 81), but in the setup() method when autoStart is true (lines 41-43), the resolve(nil) is called outside the async block (line 45).

For consistency, consider using the same pattern as in setup() where resolve(nil) is called immediately after dispatching the async work, unless you specifically need to wait for the stop operation to complete on the main thread before resolving the promise.

Copilot uses AI. Check for mistakes.
}

@objc(flush:reject:)
Expand All @@ -86,7 +92,9 @@ class PluginSessionReplayReactNative: NSObject {
@objc(teardown:reject:)
func teardown(_ resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
print("teardown")
sessionReplay.stop()
resolve(nil)
DispatchQueue.main.async {
self.sessionReplay.stop()
resolve(nil)
}
Comment on lines +97 to +98
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Inconsistent promise resolution pattern: In this method, resolve(nil) is called inside the DispatchQueue.main.async block (line 97), but in the setup() method when autoStart is true (lines 41-43), the resolve(nil) is called outside the async block (line 45).

For consistency, consider using the same pattern as in setup() where resolve(nil) is called immediately after dispatching the async work, unless you specifically need to wait for the stop operation to complete on the main thread before resolving the promise.

Suggested change
resolve(nil)
}
}
resolve(nil)

Copilot uses AI. Check for mistakes.
}
}