我在Detox上编写e2e测试,以测试应用程序。看起来,对firebase.auth().signInWithPhoneNumber(number)
的调用在调度队列中分配了一些项,但这些项似乎从未退出队列,因此测试无法进行。我的预感是,有一个网络请求正在发出的标志呼叫,永远不会解决。这是日志:
detox[41991] INFO: [APP_STATUS] The app is busy with the following tasks:
• There are 2 work items pending on the dispatch queue: "Main Queue (<OS_dispatch_queue_main: com.apple.main-thread>)".
• Run loop "Main Run Loop" is awake.
我已经阅读了这故障排除指南,看起来操作是在主线程(本机)上进行的,并且这个问题是一个等待太多问题。
是否有方法检查调度队列中的项目,以进一步了解它们是什么?我尝试过运行/usr/bin/xcrun simctl spawn <device> log stream --level debug --style compact --predicate 'process == "myapp"'
,但是我不理解输出。如果有用的话,我可以上传日志。
我希望我可以发布一些日志,有人可以帮助我找到在调度队列中项目的原因,或者指出正确的方向。我没有本地开发经验,所以设备系统日志和目标C/Swift代码对我来说毫无意义。谢谢
19.4.2
0.67.4
v12.22.6
iPhone 11 Simulator
iOS
jest-circus
发布于 2022-07-15 17:54:09
要回答以下问题:不,没有检查调度队列的简单方法。您必须查看应用程序的内部结构,添加日志记录,并注释出代码的部分,直到您知道是什么导致了问题。
编辑:从2022-08-07开始,将您的 @react-native-firebase/*
包更新为 >=v15.3.0
应该会修复这个问题。
关于你特定的同步问题..。
这个问题是由@react-native-firebase/messaging
实现application: didReceiveRemoteNotification: fetchCompletionHandler:
!中的一个错误引起的。
如果FIRAuth的函数先运行,则它们的实现将进入FIRAuth/didReceiveRemoteNotification
的争用,这会导致function本机-火基/消息传递不回调完成处理程序。
在上游修复此问题的PR正在进行中,但同时,如果您已经设置了贴片包装,则可以使用以下修补程序
diff --git a/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m b/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
index ec26b70..743fe41 100644
--- a/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
+++ b/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
@@ -123,6 +123,18 @@ - (void)application:(UIApplication *)application
completionHandler(UIBackgroundFetchResultNoData);
return;
}
+
+ // If the notification is a probe notification, always call the completion
+ // handler with UIBackgroundFetchResultNoData.
+ //
+ // This fixes a race condition between `FIRAuth/didReceiveRemoteNotification` and this
+ // module causing detox to hang when `FIRAuth/didReceiveRemoteNotification` is called first.
+ // see https://stackoverflow.com/questions/72044950/detox-tests-hang-with-pending-items-on-dispatch-queue/72989494
+ NSDictionary *data = userInfo[@"com.google.firebase.auth"];
+ if (data && data[@"warning"]) {
+ completionHandler(UIBackgroundFetchResultNoData);
+ return;
+ }
#endif
[[NSNotificationCenter defaultCenter]
!在@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
https://stackoverflow.com/questions/72044950
复制相似问题