Firestore文档创建失败,没有错误 [英] Firestore document creation fails without an error

查看:54
本文介绍了Firestore文档创建失败,没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Edit3 :好的,这似乎是Firebase的问题,其他人在推特上也提到了同样的问题.我还联系了支持部门.

Okay, it seems like it's an issue with Firebase, someone else tweeted about having the same issue. I also contacted support.

处理创建文档的Swift代码突然停止工作.没有引发任何错误,Firebase在日志中没有抱怨,我可以从控制台确认未创建该文档,可以确认该设备具有正常的Internet连接.为了确保安全,我还为Firebase禁用了离线持久性.

A piece of Swift code that handles creating documents suddenly stopped working. No errors are thrown, Firebase doesn't complain in the log and I can verify from the console that the document is not created, I can verify that the device has a healthy internet connection. I also disabled offline persistence for Firebase just to be sure.

当我尝试调试它时,调试器会直接跳过处理错误或成功的代码块,从不运行它(即从不完成Firestore请求?).

When I try debugging it, the debugger jumps straight over the block that handles errors or successes, never running it (i.e. never finishing the Firestore request?).

这是代码

    func createConversation(){
    let conversation : [String : Any] = ["owners" : [
        UserProfile().getProfile().uid!],
                                         "seeking" : true,
                                         "timestamp" : Timestamp(date: Date())
    ]

    var ref: DocumentReference? = nil
    ref = DB().firestore().collection("Conversations").addDocument(data: conversation){ err in
        if let err = err {
            print("Error creating a convo: \(err)")
        } else {
            print("Conversation created with ID: \(ref!.documentID)")
            StateMachine().action(a: .seekingStarted(ref!.documentID))


        }
        print("Conversation Creation finished")
    }
    let documentID = ref?.documentID
    print(ref.debugDescription)

}

我不确定如何解决这个问题,有什么想法吗?

I'm not sure how to approach this issue, any ideas?

好的,问题不仅限于此代码块,似乎Firebase无法与服务器通信.我已经等了5分钟以上,addDocument才返回(有错误或成功),但从未发生.

Okay, the issue is not limited to this block of code, it looks like Firebase is not communicating with the servers. I've waited for more than 5min for the addDocument to return(with error or success) but that never happened.

我注意到在启动App时BoringSSL有点抱怨,但这并不新鲜,而且其他Firebase服务也没有问题,它们运行正常-读取和创建数据没有问题.

I noticed that at the initiation of the App BoringSSL complains a bit but this is not new and I don't have problems with the other Firebase services, they work just fine - reading and creating data with no problems.

Edit2 :显然,我可以从Firestore提取集合和文档,该问题似乎仅限于文档/集合的创建.

Apparently I can fetch collections and documents from Firestore, the issue seems to be limited to document/collection creation.

推荐答案

文档创建操作会花费一些时间,如果将断点放在异步完成块中,您肯定会得到错误或成功.

The document creation operation takes a little time, if you place the breakpoint inside the asynchronus completion block you will surely get an error or success.

这篇关于Firestore文档创建失败,没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆