客户端离线,获取文档失败 [英] Failed to get document because the client is offline

查看:126
本文介绍了客户端离线,获取文档失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Flutter用于移动应用程序,最近一直注意到一个间歇性错误,该错误使得该错误导致从Cloud Firestore读取文档失败.我终于有了其中一个设备来获取该错误,因此我将其插入以获取日志,并在尝试访问其中一个文档时遇到了此错误.

I'm using Flutter for a mobile app and have been noticing a intermittent bug recently that makes it so that reading documents from cloud firestore fails. I finally got one of my devices to get the bug so I plugged it in to get logs and I got this error when I tried accessing one of the documents.

flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(Error performing get, Failed to get document because the client is offline., null)

此行代码抛出此错误,它在99.9%的时间内对99.9%的用户起作用

this error is thrown from this line of my code, which works for 99.9% of users 99.9% of the time

    DocumentSnapshot userLivestream = await Firestore.instance.collection('livestreams').document(userId).get();

我已经做了很多有关该主题的阅读,并且得到了很多混杂的答案.一篇堆栈溢出的帖子说它已像2.5年前一样被修复(显然不是,参考: Firebase Cloud Firestore抛出客户端处于脱机状态" ),而其他人则说它是特定于Android的(参考: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/631 ),但是我在Android和iOS上都遇到了相同的问题.这个问题最近变得越来越严重,所以也许这与我使用的软件包有关.这里的相关程序包是从我的pubspec.yaml中粘贴的.

I've done a lot of reading up on the topic and got a lot of mixed answers. One stack overflow post said it was fixed like 2.5 years ago(obviously not, ref: Firebase Cloud Firestore throws "client is offline"), and others said it was android specific (ref: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/631), but I am experiencing the same issue on both android and iOS. This problem has gotten worse recently, so maybe it is something with the package I am using. The relevant packages here are pasted from my pubspec.yaml.

  firebase_core: ^0.4.0+1
  cloud_firestore: ^0.11.0+1
  firebase_auth: ^0.11.1

有时该错误会在一段时间后自行修复,这可能与登录应用程序或更改设备所连接的网络有关,但是根据该信息,我仍然无法始终如一地复制该问题.有没有人遇到类似的问题,您如何解决?

sometimes the bug fixes itself after a while, it might have something to do with logging into the app or changing the network the device is connected to, but with that information I still can't consistently replicate the issue. Has anyone run into a similar issue and how did you fix it?

堆栈跟踪:

03-31 13:20:09.488 19623  6084 E flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(Error performing get, Failed to get document because the client is offline., null)
03-31 13:20:09.488 19623  6084 E flutter : #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569)
03-31 13:20:09.488 19623  6084 E flutter : #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321)
03-31 13:20:09.488 19623  6084 E flutter : <asynchronous suspension>
03-31 13:20:09.488 19623  6084 E flutter : #2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349)
03-31 13:20:09.488 19623  6084 E flutter : #3      DocumentReference.get (package:cloud_firestore/src/document_reference.dart:76)
03-31 13:20:09.488 19623  6084 E flutter : #4      LivestreamRepository.getUsersLivestream (package:hallo/repositories/livestream_repository.dart:81)
03-31 13:20:09.488 19623  6084 E flutter : #5      joinLivestream (package:hallo/presentation/widgets/livestream_previews.dart:448)
03-31 13:20:09.488 19623  6084 E flutter : #6      _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:45)
03-31 13:20:09.488 19623  6084 E flutter : #7      joinLivestream (package:hallo/presentation/widgets/livestream_previews.dart:447)
03-31 13:20:09.488 19623  6084 E flutter : #8      LiveStreamMenuState._buildLivestreamList.<anonymous closure>.<anonymous closure> (package:hallo/livestream/livestream_screen.dart:463)
03-31 13:20:09.488 19623  6084 E flutter : #9      _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:45)
03-31 13:20:09.488 19623  6084 E flutter : #10     LiveStreamMenuState._buildLivestreamList.<anonymous closure>.<anonymous closure> (package:hallo/livestream/livestream_screen.dart:460)
03-31 13:20:09.488 19623  6084 E flutter : #11     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182)
03-31 13:20:09.488 19623  6084 E flutter : #12     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486)
03-31 13:20:09.488 19623  6084 E flutter : #13     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282)
03-31 13:20:09.488 19623  6084 E flutter : #14     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236)
03-31 13:20:09.488 19623  6084 E flutter : #15     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156)
03-31 13:20:09.488 19623  6084 E flutter : #16     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222)
03-31 13:20:09.488 19623  6084 E flutter : #17     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198)
03-31 13:20:09.488 19623  6084 E flutter : #18     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156)
03-31 13:20:09.488 19623  6084 E flutter : #19     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102)
03-31 13:20:09.488 19623  6084 E flutter : #20     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86)
03-31 13:20:09.488 19623  6084 E flutter : #21     _rootRunUnary (dart:async/zone.dart:1138)
03-31 13:20:09.488 19623  6084 E flutter : #22     _CustomZone.runUnary (dart:async/zone.dart:1031)
03-31 13:20:09.488 19623  6084 E flutter : #23     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933)
03-31 13:20:09.488 19623  6084 E flutter : #24     _invoke1 (dart:ui/hooks.dart:273)
03-31 13:20:09.488 19623  6084 E flutter : #25     _dispatchPointerDataPacket (dart:ui/hooks.dart:182)

推荐答案

我遇到了同样的问题.我试图引用尚未创建的集合.因此,我刚刚使用虚拟文档创建了一个集合.现在运行良好.

I faced the same issue. I tried to reference the collection which is not yet created. So, I just created a collection with dummy doc. And now it's working good.

cloud_firestore开发人员应注意错误报告.

The cloud_firestore developers should have to take concern on error reports.

这篇关于客户端离线,获取文档失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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