@@ -61,16 +61,22 @@ import {
61
61
DocumentMap
62
62
} from '../../../src/model/collections' ;
63
63
import { Document } from '../../../src/model/document' ;
64
+ import { FieldMask } from '../../../src/model/field_mask' ;
64
65
import {
66
+ FieldTransform ,
65
67
Mutation ,
66
68
MutationResult ,
67
69
MutationType ,
70
+ PatchMutation ,
68
71
Precondition
69
72
} from '../../../src/model/mutation' ;
70
73
import {
71
74
MutationBatch ,
72
75
MutationBatchResult
73
76
} from '../../../src/model/mutation_batch' ;
77
+ import { ObjectValue } from '../../../src/model/object_value' ;
78
+ import { serverTimestamp } from '../../../src/model/server_timestamps' ;
79
+ import { ServerTimestampTransform } from '../../../src/model/transform_operation' ;
74
80
import { BundleMetadata as ProtoBundleMetadata } from '../../../src/protos/firestore_bundle_proto' ;
75
81
import * as api from '../../../src/protos/firestore_proto_api' ;
76
82
import { RemoteEvent } from '../../../src/remote/remote_event' ;
@@ -94,6 +100,7 @@ import {
94
100
docUpdateRemoteEvent ,
95
101
existenceFilterEvent ,
96
102
expectEqual ,
103
+ field ,
97
104
filter ,
98
105
key ,
99
106
localViewChanges ,
@@ -2268,6 +2275,36 @@ function genericLocalStoreTests(
2268
2275
. finish ( ) ;
2269
2276
} ) ;
2270
2277
2278
+ it ( 'deeply nested server timestamps do not cause stack overflow' , async ( ) => {
2279
+ const timestamp = Timestamp . now ( ) ;
2280
+ const initialServerTimestamp = serverTimestamp ( timestamp , null ) ;
2281
+ const value : ObjectValue = ObjectValue . empty ( ) ;
2282
+ value . set (
2283
+ field ( 'timestamp' ) ,
2284
+ serverTimestamp ( timestamp , initialServerTimestamp )
2285
+ ) ;
2286
+
2287
+ const mutations : PatchMutation [ ] = [ ] ;
2288
+ for ( let i = 0 ; i < 100 ; ++ i ) {
2289
+ mutations . push (
2290
+ new PatchMutation (
2291
+ key ( 'foo/bar' ) ,
2292
+ value ,
2293
+ new FieldMask ( [ field ( 'timestamp' ) ] ) ,
2294
+ Precondition . none ( ) ,
2295
+ [
2296
+ new FieldTransform (
2297
+ field ( 'timestamp' ) ,
2298
+ new ServerTimestampTransform ( )
2299
+ )
2300
+ ]
2301
+ )
2302
+ ) ;
2303
+ }
2304
+ await expect ( expectLocalStore ( ) . afterMutations ( mutations ) . finish ( ) ) . to . not
2305
+ . be . eventually . rejected ;
2306
+ } ) ;
2307
+
2271
2308
it ( 'uses target mapping to execute queries' , ( ) => {
2272
2309
if ( gcIsEager ) {
2273
2310
return ;
0 commit comments