New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore timestamp crashed #12437

Closed
renefloor opened this Issue Oct 6, 2017 · 21 comments

Comments

Projects
None yet
@renefloor

renefloor commented Oct 6, 2017

Steps to Reproduce

I added the firebase_firestore to my app. In the firebase console I added a document with a timestamp. I tried to get that document in my app, but than it crashes. The MethodChannel doesn't accept timestamps. I use version "^0.0.1+1".

Logs

java.lang.IllegalArgumentException: Unsupported value: Thu Sep 28 08:00:00 GMT+02:00 2017
	at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:250)
	at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:247)
	at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:247)
	at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:239)
	at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:247)
	at io.flutter.plugin.common.StandardMethodCodec.encodeMethodCall(StandardMethodCodec.java:31)
	at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:82)
	at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:69)
@sethladd

This comment has been minimized.

Contributor

sethladd commented Oct 6, 2017

@collinjackson

This comment has been minimized.

Contributor

collinjackson commented Oct 6, 2017

Are you trying to use the current server timestamp value or some other DateTime value?

If it's the former, we have a solution for firebase_database and should investigate whether to do the same for Firestore.

@renefloor

This comment has been minimized.

renefloor commented Oct 6, 2017

@collinjackson Not sure what the data type is, I was trying to figure that out. I create a document directly in the firebase console as type timestamp. Is that what you mean with "the current server timestamp"?
screen shot 2017-10-06 at 20 41 30

@pauldemarco

This comment has been minimized.

pauldemarco commented Oct 7, 2017

One approach would be to convert Dart "DateTime" objects to standard UTC microseconds for transport over the channel, than convert into the appropriate Android/iOS date types (or whatever the firestore SDK's are using).

Looking forward to this, keep up the good work :)

@collinjackson

This comment has been minimized.

Contributor

collinjackson commented Oct 9, 2017

@pauldemarco I agree, the only question is whether this should be done automatically by the plugin system or whether we should make every plugin do it manually.

@pauldemarco

This comment has been minimized.

pauldemarco commented Oct 9, 2017

IMO, since the timestamp is a propriety Firestore data type, it would be okay to let the conversion to and from DateTime happen automatically within the plugin. That is how the web SDK for Firestore handles it, we simply send/receive Javascript Date objects to and from.

@renefloor

This comment has been minimized.

renefloor commented Oct 9, 2017

@collinjackson do you have any idea whether this can be fixed soon like next week or that I should make a work around for now?

@collinjackson

This comment has been minimized.

Contributor

collinjackson commented Oct 9, 2017

It looks like it should be a pretty easy fix... I am busy for the next few days but happy to review pull requests on the flutter/plugins repo if you want a fix faster -- just make sure to tag me on them.

@renefloor

This comment has been minimized.

renefloor commented Oct 9, 2017

I don't have much time either. Will make a pull request when it isn't fixed before I have time.

@pauldemarco

This comment has been minimized.

pauldemarco commented Oct 12, 2017

It doesn't look like there's a hidden solution to this: https://groups.google.com/forum/#!topic/google-cloud-firestore-discuss/VKFNZhcF3qQ

I'm attempting to create a custom codec that considers these new types, and automatically converts them as they come across the channel.

@lucamtudor

This comment has been minimized.

lucamtudor commented Feb 28, 2018

any progress?

@todorescu

This comment has been minimized.

todorescu commented Feb 28, 2018

Wondering about the progress as well...

@outermeasure

This comment has been minimized.

outermeasure commented Feb 28, 2018

Would anyone know what would be a good workaround?

@kenticus

This comment has been minimized.

kenticus commented Feb 28, 2018

@collinjackson did you guys make any headway on this one? It's currently a blocker for us.

@lucamtudor

This comment has been minimized.

lucamtudor commented Mar 1, 2018

If you need to unblock your project, use the following fork (it has been updated with master) in your pubspec.yaml:

dependencies:
  cloud_firestore:
    git:
      url: git@github.com:theshiftstudio/flutter_plugins.git
      ref: 9cabcc57e63fbc9be4fafee08e6435a1a8c71d61
      path: packages/cloud_firestore
@bjornbjorn

This comment has been minimized.

bjornbjorn commented Mar 7, 2018

We've worked around this by making sure all dates are stored as strings in Firestore. However, we do a lot of import of data from external providers, and sometimes a timestamp will sneak itself into our dataset. That is currently a huge pain cause it will crash the app, and we'll have to find the offending timestamp (not always easy), remove it/convert to string, and then tell all beta testers to uninstall the app and reinstall it (since data is cached on the client).

So, hopefully this will be fixed soon :)

@ashtonthomas

This comment has been minimized.

ashtonthomas commented Mar 7, 2018

FWIW, I'm hitting this issue with timestamp as well as FIRDocumentReference (stack trace below).

I'm going to limp along using Strings or removing the fields if I can do without for now.

timestamp

Unsupported value: Thu Oct 10 00:00:00 1987 of type __NSTaggedDate
Lost connection to device.
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010aaf812b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010a194f41 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010aafd2f2 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00000001082a1d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   Flutter                             0x0000000108a98692 -[FlutterStandardWriter writeValue:] + 2110
	5   Flutter                             0x0000000108a985b8 -[FlutterStandardWriter writeValue:] + 1892
	6   Flutter                             0x0000000108a985b8 -[FlutterStandardWriter writeValue:] + 1892
	7   Flutter                             0x0000000108a98443 -[FlutterStandardWriter writeValue:] + 1519
	8   Flutter    <…>

FIRDocumentReference

Unsupported value: <FIRDocumentReference: 0x60400142d2e0> of type FIRDocumentReference
SNAP: {name: half marathon}
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010f3b112b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010ea45f41 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010f3b62f2 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x000000010e4e6d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   Flutter                             0x000000010c609692 -[FlutterStandardWriter writeValue:] + 2110
	5   Flutter                             0x000000010c609443 -[FlutterStandardWriter writeValue:] + 1519
	6   Flutter                             0x000000010c6095b8 -[FlutterStandardWriter writeValue:] + 1892
	7   Flutter                             0x000000010c6095b8 -[FlutterStandardWriter writeValue:] + 1892
	8   Flutter    <…>
Lost connection to device.
@Samaritan1011001

This comment has been minimized.

Samaritan1011001 commented Mar 13, 2018

Any update on this?

@bjornbjorn

This comment has been minimized.

bjornbjorn commented Mar 13, 2018

It's being worked on here: flutter/plugins#343

Looks like we're getting close 👍

@jlouage

This comment has been minimized.

jlouage commented Mar 15, 2018

any update???

@Skylled

This comment has been minimized.

Contributor

Skylled commented Mar 23, 2018

Can be closed, via flutter/plugins#429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment