Skip to content

Commit 8a5af1d

Browse files
authored
store init err for logging (#29104)
1 parent 9602c11 commit 8a5af1d

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

rnmodules/react-native-kb/ios/Kb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ FOUNDATION_EXPORT void KbSetDeviceToken(NSString *token);
2424
FOUNDATION_EXPORT void KbSetInitialNotification(NSDictionary *notification);
2525
FOUNDATION_EXPORT void KbEmitPushNotification(NSDictionary *notification);
2626
FOUNDATION_EXPORT NSDictionary *KbGetAndClearInitialNotification(void);
27+
28+
// Init result - stored for inclusion in ReadArr error logs
29+
FOUNDATION_EXPORT void KbSetInitResult(NSString *result);

rnmodules/react-native-kb/ios/Kb.mm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ - (void)dealloc {
7878
static BOOL kbPasteImageEnabled = NO;
7979
static NSString *kbStoredDeviceToken = nil;
8080
static NSDictionary *kbInitialNotification = nil;
81+
static NSString *kbInitResult = nil;
8182

8283
@interface RCTBridge (JSIRuntime)
8384
- (void *)runtime;
@@ -396,10 +397,11 @@ - (NSDictionary *)getConstants {
396397
}
397398
if (consecutiveErrors <= 5 || consecutiveErrors % 50 == 0) {
398399
__typeof__(self) strongSelf = weakSelf;
399-
os_log(OS_LOG_DEFAULT, "ReadArr loop[%llu] error streak=%llu total=%llu domain=%{public}s code=%ld desc=%{public}s self=%p bridge=%p jsRuntime=%p currentRuntime=%p",
400+
os_log(OS_LOG_DEFAULT, "ReadArr loop[%llu] error streak=%llu total=%llu domain=%{public}s code=%ld desc=%{public}s initResult=%{public}s self=%p bridge=%p jsRuntime=%p currentRuntime=%p",
400401
(unsigned long long)readLoopGen, (unsigned long long)consecutiveErrors,
401402
(unsigned long long)totalErrors, KBStringOrNil(error.domain), (long)error.code,
402-
KBStringOrNil(error.localizedDescription), strongSelf, strongSelf.bridge,
403+
KBStringOrNil(error.localizedDescription), KBStringOrNil(kbInitResult),
404+
strongSelf, strongSelf.bridge,
403405
strongSelf ? [strongSelf javaScriptRuntimePointer] : nil, currentRuntime);
404406
}
405407
// Back off on error to avoid spinning at ~35K/sec and starving the main thread CPU
@@ -752,3 +754,7 @@ void KbEmitPushNotification(NSDictionary *notification) {
752754
kbInitialNotification = nil;
753755
return notification;
754756
}
757+
758+
void KbSetInitResult(NSString *result) {
759+
kbInitResult = result;
760+
}

shared/ios/Keybase/AppDelegate.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,17 @@ public class AppDelegate: ExpoAppDelegate, UNUserNotificationCenterDelegate,
254254
securityAccessGroupOverride, nil, nil, systemVer, isIPad, nil, isIOS, shareIntentDonator, &err
255255
)
256256
if let err {
257+
let initResult = "FAILED: \(err.localizedDescription) (code=\(err.code) domain=\(err.domain))"
258+
KbSetInitResult(initResult)
257259
// Log to system log with public annotation so it's not redacted in logarchive.
258260
os_log(
259261
.error, log: AppDelegate.initLog,
260262
"KeybaseInit FAILED: %{public}@ (code=%ld domain=%{public}@)",
261263
err.localizedDescription, err.code, err.domain)
262264
// Also write to ios.log so it's captured in xcappdata even without a device attached.
263-
self.writeStartupTimingLog(
264-
"KeybaseInit FAILED: \(err.localizedDescription) (code=\(err.code) domain=\(err.domain))")
265+
self.writeStartupTimingLog("KeybaseInit \(initResult)")
265266
} else {
267+
KbSetInitResult("succeeded")
266268
self.writeStartupTimingLog("KeybaseInit succeeded")
267269
}
268270

0 commit comments

Comments
 (0)