@fluidframework/driver-utils 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.eslintrc.js +17 -19
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/blobAggregationStorage.d.ts +15 -2
  5. package/dist/blobAggregationStorage.d.ts.map +1 -1
  6. package/dist/blobAggregationStorage.js +22 -13
  7. package/dist/blobAggregationStorage.js.map +1 -1
  8. package/dist/blobCacheStorageService.d.ts.map +1 -1
  9. package/dist/blobCacheStorageService.js.map +1 -1
  10. package/dist/buildSnapshotTree.d.ts.map +1 -1
  11. package/dist/buildSnapshotTree.js.map +1 -1
  12. package/dist/documentStorageServiceProxy.d.ts.map +1 -1
  13. package/dist/documentStorageServiceProxy.js.map +1 -1
  14. package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
  15. package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
  16. package/dist/error.d.ts.map +1 -1
  17. package/dist/error.js.map +1 -1
  18. package/dist/fluidResolvedUrl.d.ts.map +1 -1
  19. package/dist/fluidResolvedUrl.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/insecureUrlResolver.d.ts.map +1 -1
  24. package/dist/insecureUrlResolver.js +2 -1
  25. package/dist/insecureUrlResolver.js.map +1 -1
  26. package/dist/mapWithExpiration.d.ts.map +1 -1
  27. package/dist/mapWithExpiration.js +5 -3
  28. package/dist/mapWithExpiration.js.map +1 -1
  29. package/dist/messageRecognition.d.ts.map +1 -1
  30. package/dist/messageRecognition.js.map +1 -1
  31. package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
  32. package/dist/multiDocumentServiceFactory.js.map +1 -1
  33. package/dist/multiUrlResolver.d.ts.map +1 -1
  34. package/dist/multiUrlResolver.js.map +1 -1
  35. package/dist/network.d.ts +1 -1
  36. package/dist/network.d.ts.map +1 -1
  37. package/dist/network.js +4 -3
  38. package/dist/network.js.map +1 -1
  39. package/dist/networkUtils.d.ts.map +1 -1
  40. package/dist/networkUtils.js +2 -3
  41. package/dist/networkUtils.js.map +1 -1
  42. package/dist/packageVersion.d.ts +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/parallelRequests.d.ts.map +1 -1
  46. package/dist/parallelRequests.js +19 -9
  47. package/dist/parallelRequests.js.map +1 -1
  48. package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
  49. package/dist/prefetchDocumentStorageService.js.map +1 -1
  50. package/dist/rateLimiter.d.ts.map +1 -1
  51. package/dist/rateLimiter.js.map +1 -1
  52. package/dist/readAndParse.d.ts.map +1 -1
  53. package/dist/readAndParse.js.map +1 -1
  54. package/dist/runWithRetry.d.ts.map +1 -1
  55. package/dist/runWithRetry.js.map +1 -1
  56. package/dist/summaryForCreateNew.d.ts.map +1 -1
  57. package/dist/summaryForCreateNew.js.map +1 -1
  58. package/dist/treeConversions.d.ts.map +1 -1
  59. package/dist/treeConversions.js +1 -4
  60. package/dist/treeConversions.js.map +1 -1
  61. package/dist/treeUtils.d.ts +10 -10
  62. package/dist/treeUtils.d.ts.map +1 -1
  63. package/dist/treeUtils.js +10 -10
  64. package/dist/treeUtils.js.map +1 -1
  65. package/lib/blobAggregationStorage.d.ts +15 -2
  66. package/lib/blobAggregationStorage.d.ts.map +1 -1
  67. package/lib/blobAggregationStorage.js +22 -13
  68. package/lib/blobAggregationStorage.js.map +1 -1
  69. package/lib/blobCacheStorageService.d.ts.map +1 -1
  70. package/lib/blobCacheStorageService.js.map +1 -1
  71. package/lib/buildSnapshotTree.d.ts.map +1 -1
  72. package/lib/buildSnapshotTree.js.map +1 -1
  73. package/lib/documentStorageServiceProxy.d.ts.map +1 -1
  74. package/lib/documentStorageServiceProxy.js.map +1 -1
  75. package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
  76. package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
  77. package/lib/error.d.ts.map +1 -1
  78. package/lib/error.js.map +1 -1
  79. package/lib/fluidResolvedUrl.d.ts.map +1 -1
  80. package/lib/fluidResolvedUrl.js.map +1 -1
  81. package/lib/index.d.ts +1 -1
  82. package/lib/index.d.ts.map +1 -1
  83. package/lib/index.js +1 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/insecureUrlResolver.d.ts.map +1 -1
  86. package/lib/insecureUrlResolver.js +2 -1
  87. package/lib/insecureUrlResolver.js.map +1 -1
  88. package/lib/mapWithExpiration.d.ts.map +1 -1
  89. package/lib/mapWithExpiration.js +5 -3
  90. package/lib/mapWithExpiration.js.map +1 -1
  91. package/lib/messageRecognition.d.ts.map +1 -1
  92. package/lib/messageRecognition.js +1 -1
  93. package/lib/messageRecognition.js.map +1 -1
  94. package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
  95. package/lib/multiDocumentServiceFactory.js.map +1 -1
  96. package/lib/multiUrlResolver.d.ts.map +1 -1
  97. package/lib/multiUrlResolver.js.map +1 -1
  98. package/lib/network.d.ts +1 -1
  99. package/lib/network.d.ts.map +1 -1
  100. package/lib/network.js +4 -3
  101. package/lib/network.js.map +1 -1
  102. package/lib/networkUtils.d.ts.map +1 -1
  103. package/lib/networkUtils.js +2 -3
  104. package/lib/networkUtils.js.map +1 -1
  105. package/lib/packageVersion.d.ts +1 -1
  106. package/lib/packageVersion.js +1 -1
  107. package/lib/packageVersion.js.map +1 -1
  108. package/lib/parallelRequests.d.ts.map +1 -1
  109. package/lib/parallelRequests.js +19 -9
  110. package/lib/parallelRequests.js.map +1 -1
  111. package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
  112. package/lib/prefetchDocumentStorageService.js.map +1 -1
  113. package/lib/rateLimiter.d.ts.map +1 -1
  114. package/lib/rateLimiter.js.map +1 -1
  115. package/lib/readAndParse.d.ts.map +1 -1
  116. package/lib/readAndParse.js.map +1 -1
  117. package/lib/runWithRetry.d.ts.map +1 -1
  118. package/lib/runWithRetry.js.map +1 -1
  119. package/lib/summaryForCreateNew.d.ts.map +1 -1
  120. package/lib/summaryForCreateNew.js.map +1 -1
  121. package/lib/treeConversions.d.ts.map +1 -1
  122. package/lib/treeConversions.js +4 -7
  123. package/lib/treeConversions.js.map +1 -1
  124. package/lib/treeUtils.d.ts +10 -10
  125. package/lib/treeUtils.d.ts.map +1 -1
  126. package/lib/treeUtils.js +11 -11
  127. package/lib/treeUtils.js.map +1 -1
  128. package/package.json +43 -64
  129. package/prettier.config.cjs +1 -1
  130. package/src/blobAggregationStorage.ts +380 -324
  131. package/src/blobCacheStorageService.ts +20 -17
  132. package/src/buildSnapshotTree.ts +54 -51
  133. package/src/documentStorageServiceProxy.ts +49 -43
  134. package/src/emptyDocumentDeltaStorageService.ts +11 -10
  135. package/src/error.ts +5 -7
  136. package/src/fluidResolvedUrl.ts +9 -6
  137. package/src/index.ts +5 -1
  138. package/src/insecureUrlResolver.ts +127 -116
  139. package/src/mapWithExpiration.ts +111 -104
  140. package/src/messageRecognition.ts +25 -19
  141. package/src/multiDocumentServiceFactory.ts +73 -62
  142. package/src/multiUrlResolver.ts +26 -29
  143. package/src/network.ts +114 -112
  144. package/src/networkUtils.ts +37 -34
  145. package/src/packageVersion.ts +1 -1
  146. package/src/parallelRequests.ts +571 -509
  147. package/src/prefetchDocumentStorageService.ts +76 -74
  148. package/src/rateLimiter.ts +29 -29
  149. package/src/readAndParse.ts +7 -4
  150. package/src/runWithRetry.ts +105 -94
  151. package/src/summaryForCreateNew.ts +27 -24
  152. package/src/treeConversions.ts +48 -70
  153. package/src/treeUtils.ts +70 -74
  154. package/tsconfig.esnext.json +6 -6
  155. package/tsconfig.json +8 -12
@@ -30,274 +30,307 @@ type WorkingState = "working" | "done" | "canceled";
30
30
  * @returns - Queue that can be used to retrieve data
31
31
  */
32
32
  export class ParallelRequests<T> {
33
- private latestRequested: number;
34
- private nextToDeliver: number;
35
- private readonly results: Map<number, T[]> = new Map();
36
- private workingState: WorkingState = "working";
37
- private requestsInFlight = 0;
38
- private readonly endEvent = new Deferred<void>();
39
- private requests = 0;
40
- private readonly knewTo: boolean;
41
-
42
- private get working() { return this.workingState === "working"; }
43
- public get canceled() { return this.workingState === "canceled"; }
44
-
45
- constructor(
46
- from: number,
47
- private to: number | undefined,
48
- private readonly payloadSize: number,
49
- private readonly logger: ITelemetryLogger,
50
- private readonly requestCallback: (
51
- request: number,
52
- from: number,
53
- to: number,
54
- strongTo: boolean,
55
- props: ITelemetryProperties) => Promise<{ partial: boolean; cancel: boolean; payload: T[]; }>,
56
- private readonly responseCallback: (payload: T[]) => void) {
57
- this.latestRequested = from;
58
- this.nextToDeliver = from;
59
- this.knewTo = (to !== undefined);
60
- }
61
-
62
- public cancel() {
63
- if (this.working) {
64
- this.workingState = "canceled";
65
- this.endEvent.resolve();
66
- }
67
- }
68
-
69
- public async run(concurrency: number) {
70
- assert(concurrency > 0, 0x102 /* "invalid level of concurrency" */);
71
- assert(this.working, 0x103 /* "trying to parallel run while not working" */);
72
-
73
- let c = concurrency;
74
- while (c > 0) {
75
- c--;
76
- this.addRequest();
77
- }
78
- this.dispatch();// will recalculate and trigger this.endEvent if needed
79
- return this.endEvent.promise;
80
- }
81
-
82
- private done() {
83
- // We should satisfy request fully.
84
- assert(this.to !== undefined, 0x104 /* "undefined end point for parallel fetch" */);
85
- assert(this.nextToDeliver >= this.to, 0x105 /* "unexpected end point for parallel fetch" */);
86
- if (this.working) {
87
- this.workingState = "done";
88
- this.endEvent.resolve();
89
- }
90
- }
91
-
92
- private fail(error) {
93
- if (this.working) {
94
- this.workingState = "done";
95
- this.endEvent.reject(error);
96
- }
97
- }
98
-
99
- private dispatch() {
100
- while (this.working) {
101
- const value = this.results.get(this.nextToDeliver);
102
- if (value === undefined) {
103
- break;
104
- }
105
- this.results.delete(this.nextToDeliver);
106
- assert(value.length <= this.payloadSize, 0x1d9 /* "addRequestCore() should break into smaller chunks" */);
107
- this.nextToDeliver += value.length;
108
- this.responseCallback(value);
109
- }
110
-
111
- // Account for cancellation - state might be not in consistent state on cancelling operation
112
- if (this.working) {
113
- if (this.requestsInFlight === 0) {
114
- // we should have dispatched everything, no matter whether we knew about the end or not.
115
- // see comment in addRequestCore() around throwing away chunk if it's above this.to
116
- assert(this.results.size === 0,
117
- 0x107 /* "ending dispatch with remaining results to be sent" */);
118
- this.done();
119
- } else if (this.to !== undefined && this.nextToDeliver >= this.to) {
120
- // Learned about the end and dispatched all the ops up to it.
121
- // Ignore all the in-flight requests above boundary - unblock caller sooner.
122
- assert(!this.knewTo, 0x108 /* "ending results dispatch but knew in advance about more requests" */);
123
- this.done();
124
- }
125
- }
126
- }
127
-
128
- private getNextChunk() {
129
- if (!this.working) {
130
- return undefined;
131
- }
132
-
133
- const from = this.latestRequested;
134
- if (this.to !== undefined) {
135
- if (this.to <= from) {
136
- return undefined;
137
- }
138
- }
139
-
140
- // this.latestRequested
141
- // inclusive on the right side! Exclusive on the left.
142
- this.latestRequested += this.payloadSize;
143
-
144
- if (this.to !== undefined) {
145
- this.latestRequested = Math.min(this.to, this.latestRequested);
146
- }
147
-
148
- assert(from < this.latestRequested, 0x109 /* "unexpected next chunk position" */);
149
-
150
- return { from, to: this.latestRequested };
151
- }
152
-
153
- private addRequest() {
154
- const chunk = this.getNextChunk();
155
- if (chunk === undefined) {
156
- return;
157
- }
158
- this.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));
159
- }
160
-
161
- private async addRequestCore(fromArg: number, toArg: number) {
162
- assert(this.working, 0x10a /* "cannot add parallel request while not working" */);
163
-
164
- let from = fromArg;
165
- let to = toArg;
166
-
167
- // to & from are exclusive
168
- this.requestsInFlight++;
169
- while (this.working) {
170
- const requestedLength = to - from;
171
- assert(requestedLength > 0, 0x10b /* "invalid parallel request range" */);
172
-
173
- // We should not be wasting time asking for something useless.
174
- if (this.to !== undefined) {
175
- assert(from < this.to, 0x10c /* "invalid parallel request start point" */);
176
- assert(to <= this.to, 0x10d /* "invalid parallel request end point" */);
177
- }
178
-
179
- this.requests++;
180
-
181
- const promise = this.requestCallback(this.requests, from, to, this.to !== undefined, {});
182
-
183
- // dispatch any prior received data
184
- this.dispatch();
185
-
186
- const { payload, cancel, partial } = await promise;
187
-
188
- if (cancel) {
189
- this.cancel();
190
- }
191
-
192
- if (this.to !== undefined && from >= this.to) {
193
- // while we were waiting for response, we learned on what is the boundary
194
- // We can get here (with actual result!) if situation changed while this request was in
195
- // flight, i.e. the end was extended over what we learn in some other request
196
- // While it's useful not to throw this result, this is very corner cases and makes logic
197
- // (including consistency checks) much harder to write correctly.
198
- // So for now, we are throwing this result out the window.
199
- assert(!this.knewTo, 0x10e /* "should not throw result if we knew about boundary in advance" */);
200
- // Learn how often it happens and if it's too wasteful to throw these chunks.
201
- // If it pops into our view a lot, we would need to reconsider how we approach it.
202
- // Note that this is not visible to user other than potentially not hitting 100% of
203
- // what we can in perf domain.
204
- if (payload.length !== 0) {
205
- this.logger.sendErrorEvent({
206
- eventName: "ParallelRequests_GotExtra",
207
- from,
208
- to,
209
- end: this.to,
210
- length: payload.length,
211
- });
212
- }
213
-
214
- break;
215
- }
216
-
217
- if (this.working) {
218
- const fromOrig = from;
219
- const length = payload.length;
220
- let fullChunk = (requestedLength <= length); // we can possible get more than we asked.
221
-
222
- if (length !== 0) {
223
- // We can get more than we asked for!
224
- // This can screw up logic in dispatch!
225
- // So push only batch size, and keep the rest for later - if conditions are favorable, we
226
- // will be able to use it. If not (parallel request overlapping these ops), it's easier to
227
- // discard them and wait for another (overlapping) request to come in later.
228
- if (requestedLength < length) {
229
- // This is error in a sense that it's not expected and likely points bug in other layer.
230
- // This layer copes with this situation just fine.
231
- this.logger.sendTelemetryEvent({
232
- eventName: "ParallelRequests_Over",
233
- from,
234
- to,
235
- length,
236
- });
237
- }
238
- const data = payload.splice(0, requestedLength);
239
- this.results.set(from, data);
240
- from += data.length;
241
- } else {
242
- // 1. empty (partial) chunks should not be returned by various caching / adapter layers -
243
- // they should fall back to next layer. This might be important invariant to hold to ensure
244
- // that we are less likely have bugs where such layer would keep returning empty partial
245
- // result on each call.
246
- // 2. Current invariant is that callback does retries until it gets something,
247
- // with the goal of failing if zero data is retrieved in given amount of time.
248
- // This is very specific property of storage / ops, so this logic is not here, but given only
249
- // one user of this class, we assert that to catch issues earlier.
250
- // These invariant can be relaxed if needed.
251
- assert(!partial, 0x10f /* "empty/partial chunks should not be returned by caching" */);
252
- assert(!this.knewTo,
253
- 0x110 /* "callback should retry until valid fetch before it learns new boundary" */);
254
- }
255
-
256
- if (!partial && !fullChunk) {
257
- if (!this.knewTo) {
258
- if (this.to === undefined || this.to > from) {
259
- // The END
260
- this.to = from;
261
- }
262
- break;
263
- }
264
- // We know that there are more items to be retrieved
265
- // Can we get partial chunk? Ideally storage indicates that's not a full chunk
266
- // Note that it's possible that not all ops hit storage yet.
267
- // We will come back to request more, and if we can't get any more ops soon, it's
268
- // catastrophic failure (see comment above on responsibility of callback to return something)
269
- // This layer will just keep trying until it gets full set.
270
- this.logger.sendPerformanceEvent({
271
- eventName: "ParallelRequests_Partial",
272
- from: fromOrig,
273
- to,
274
- length,
275
- });
276
- }
277
-
278
- if (to === this.latestRequested) {
279
- // we can go after full chunk at the end if we received partial chunk, or more than asked
280
- // Also if we got more than we asked to, we can actually use those ops!
281
- if (payload.length !== 0) {
282
- this.results.set(from, payload);
283
- from += payload.length;
284
- }
285
-
286
- this.latestRequested = from;
287
- fullChunk = true;
288
- }
289
-
290
- if (fullChunk) {
291
- const chunk = this.getNextChunk();
292
- if (chunk === undefined) { break; }
293
- from = chunk.from;
294
- to = chunk.to;
295
- }
296
- }
297
- }
298
- this.requestsInFlight--;
299
- this.dispatch();
300
- }
33
+ private latestRequested: number;
34
+ private nextToDeliver: number;
35
+ private readonly results: Map<number, T[]> = new Map();
36
+ private workingState: WorkingState = "working";
37
+ private requestsInFlight = 0;
38
+ private readonly endEvent = new Deferred<void>();
39
+ private requests = 0;
40
+ private readonly knewTo: boolean;
41
+
42
+ private get working() {
43
+ return this.workingState === "working";
44
+ }
45
+ public get canceled() {
46
+ return this.workingState === "canceled";
47
+ }
48
+
49
+ constructor(
50
+ from: number,
51
+ private to: number | undefined,
52
+ private readonly payloadSize: number,
53
+ private readonly logger: ITelemetryLogger,
54
+ private readonly requestCallback: (
55
+ request: number,
56
+ from: number,
57
+ to: number,
58
+ strongTo: boolean,
59
+ props: ITelemetryProperties,
60
+ ) => Promise<{ partial: boolean; cancel: boolean; payload: T[] }>,
61
+ private readonly responseCallback: (payload: T[]) => void,
62
+ ) {
63
+ this.latestRequested = from;
64
+ this.nextToDeliver = from;
65
+ this.knewTo = to !== undefined;
66
+ }
67
+
68
+ public cancel() {
69
+ if (this.working) {
70
+ this.workingState = "canceled";
71
+ this.endEvent.resolve();
72
+ }
73
+ }
74
+
75
+ public async run(concurrency: number) {
76
+ assert(concurrency > 0, 0x102 /* "invalid level of concurrency" */);
77
+ assert(this.working, 0x103 /* "trying to parallel run while not working" */);
78
+
79
+ let c = concurrency;
80
+ while (c > 0) {
81
+ c--;
82
+ this.addRequest();
83
+ }
84
+ this.dispatch(); // will recalculate and trigger this.endEvent if needed
85
+ return this.endEvent.promise;
86
+ }
87
+
88
+ private done() {
89
+ // We should satisfy request fully.
90
+ assert(this.to !== undefined, 0x104 /* "undefined end point for parallel fetch" */);
91
+ assert(
92
+ this.nextToDeliver >= this.to,
93
+ 0x105 /* "unexpected end point for parallel fetch" */,
94
+ );
95
+ if (this.working) {
96
+ this.workingState = "done";
97
+ this.endEvent.resolve();
98
+ }
99
+ }
100
+
101
+ private fail(error) {
102
+ if (this.working) {
103
+ this.workingState = "done";
104
+ this.endEvent.reject(error);
105
+ }
106
+ }
107
+
108
+ private dispatch() {
109
+ while (this.working) {
110
+ const value = this.results.get(this.nextToDeliver);
111
+ if (value === undefined) {
112
+ break;
113
+ }
114
+ this.results.delete(this.nextToDeliver);
115
+ assert(
116
+ value.length <= this.payloadSize,
117
+ 0x1d9 /* "addRequestCore() should break into smaller chunks" */,
118
+ );
119
+ this.nextToDeliver += value.length;
120
+ this.responseCallback(value);
121
+ }
122
+
123
+ // Account for cancellation - state might be not in consistent state on cancelling operation
124
+ if (this.working) {
125
+ if (this.requestsInFlight === 0) {
126
+ // we should have dispatched everything, no matter whether we knew about the end or not.
127
+ // see comment in addRequestCore() around throwing away chunk if it's above this.to
128
+ assert(
129
+ this.results.size === 0,
130
+ 0x107 /* "ending dispatch with remaining results to be sent" */,
131
+ );
132
+ this.done();
133
+ } else if (this.to !== undefined && this.nextToDeliver >= this.to) {
134
+ // Learned about the end and dispatched all the ops up to it.
135
+ // Ignore all the in-flight requests above boundary - unblock caller sooner.
136
+ assert(
137
+ !this.knewTo,
138
+ 0x108 /* "ending results dispatch but knew in advance about more requests" */,
139
+ );
140
+ this.done();
141
+ }
142
+ }
143
+ }
144
+
145
+ private getNextChunk() {
146
+ if (!this.working) {
147
+ return undefined;
148
+ }
149
+
150
+ const from = this.latestRequested;
151
+ if (this.to !== undefined) {
152
+ if (this.to <= from) {
153
+ return undefined;
154
+ }
155
+ }
156
+
157
+ // this.latestRequested
158
+ // inclusive on the right side! Exclusive on the left.
159
+ this.latestRequested += this.payloadSize;
160
+
161
+ if (this.to !== undefined) {
162
+ this.latestRequested = Math.min(this.to, this.latestRequested);
163
+ }
164
+
165
+ assert(from < this.latestRequested, 0x109 /* "unexpected next chunk position" */);
166
+
167
+ return { from, to: this.latestRequested };
168
+ }
169
+
170
+ private addRequest() {
171
+ const chunk = this.getNextChunk();
172
+ if (chunk === undefined) {
173
+ return;
174
+ }
175
+ this.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));
176
+ }
177
+
178
+ private async addRequestCore(fromArg: number, toArg: number) {
179
+ assert(this.working, 0x10a /* "cannot add parallel request while not working" */);
180
+
181
+ let from = fromArg;
182
+ let to = toArg;
183
+
184
+ // to & from are exclusive
185
+ this.requestsInFlight++;
186
+ while (this.working) {
187
+ const requestedLength = to - from;
188
+ assert(requestedLength > 0, 0x10b /* "invalid parallel request range" */);
189
+
190
+ // We should not be wasting time asking for something useless.
191
+ if (this.to !== undefined) {
192
+ assert(from < this.to, 0x10c /* "invalid parallel request start point" */);
193
+ assert(to <= this.to, 0x10d /* "invalid parallel request end point" */);
194
+ }
195
+
196
+ this.requests++;
197
+
198
+ const promise = this.requestCallback(
199
+ this.requests,
200
+ from,
201
+ to,
202
+ this.to !== undefined,
203
+ {},
204
+ );
205
+
206
+ // dispatch any prior received data
207
+ this.dispatch();
208
+
209
+ const { payload, cancel, partial } = await promise;
210
+
211
+ if (cancel) {
212
+ this.cancel();
213
+ }
214
+
215
+ if (this.to !== undefined && from >= this.to) {
216
+ // while we were waiting for response, we learned on what is the boundary
217
+ // We can get here (with actual result!) if situation changed while this request was in
218
+ // flight, i.e. the end was extended over what we learn in some other request
219
+ // While it's useful not to throw this result, this is very corner cases and makes logic
220
+ // (including consistency checks) much harder to write correctly.
221
+ // So for now, we are throwing this result out the window.
222
+ assert(
223
+ !this.knewTo,
224
+ 0x10e /* "should not throw result if we knew about boundary in advance" */,
225
+ );
226
+ // Learn how often it happens and if it's too wasteful to throw these chunks.
227
+ // If it pops into our view a lot, we would need to reconsider how we approach it.
228
+ // Note that this is not visible to user other than potentially not hitting 100% of
229
+ // what we can in perf domain.
230
+ if (payload.length !== 0) {
231
+ this.logger.sendErrorEvent({
232
+ eventName: "ParallelRequests_GotExtra",
233
+ from,
234
+ to,
235
+ end: this.to,
236
+ length: payload.length,
237
+ });
238
+ }
239
+
240
+ break;
241
+ }
242
+
243
+ if (this.working) {
244
+ const fromOrig = from;
245
+ const length = payload.length;
246
+ let fullChunk = requestedLength <= length; // we can possible get more than we asked.
247
+
248
+ if (length !== 0) {
249
+ // We can get more than we asked for!
250
+ // This can screw up logic in dispatch!
251
+ // So push only batch size, and keep the rest for later - if conditions are favorable, we
252
+ // will be able to use it. If not (parallel request overlapping these ops), it's easier to
253
+ // discard them and wait for another (overlapping) request to come in later.
254
+ if (requestedLength < length) {
255
+ // This is error in a sense that it's not expected and likely points bug in other layer.
256
+ // This layer copes with this situation just fine.
257
+ this.logger.sendTelemetryEvent({
258
+ eventName: "ParallelRequests_Over",
259
+ from,
260
+ to,
261
+ length,
262
+ });
263
+ }
264
+ const data = payload.splice(0, requestedLength);
265
+ this.results.set(from, data);
266
+ from += data.length;
267
+ } else {
268
+ // 1. empty (partial) chunks should not be returned by various caching / adapter layers -
269
+ // they should fall back to next layer. This might be important invariant to hold to ensure
270
+ // that we are less likely have bugs where such layer would keep returning empty partial
271
+ // result on each call.
272
+ // 2. Current invariant is that callback does retries until it gets something,
273
+ // with the goal of failing if zero data is retrieved in given amount of time.
274
+ // This is very specific property of storage / ops, so this logic is not here, but given only
275
+ // one user of this class, we assert that to catch issues earlier.
276
+ // These invariant can be relaxed if needed.
277
+ assert(
278
+ !partial,
279
+ 0x10f /* "empty/partial chunks should not be returned by caching" */,
280
+ );
281
+ assert(
282
+ !this.knewTo,
283
+ 0x110 /* "callback should retry until valid fetch before it learns new boundary" */,
284
+ );
285
+ }
286
+
287
+ if (!partial && !fullChunk) {
288
+ if (!this.knewTo) {
289
+ if (this.to === undefined || this.to > from) {
290
+ // The END
291
+ this.to = from;
292
+ }
293
+ break;
294
+ }
295
+ // We know that there are more items to be retrieved
296
+ // Can we get partial chunk? Ideally storage indicates that's not a full chunk
297
+ // Note that it's possible that not all ops hit storage yet.
298
+ // We will come back to request more, and if we can't get any more ops soon, it's
299
+ // catastrophic failure (see comment above on responsibility of callback to return something)
300
+ // This layer will just keep trying until it gets full set.
301
+ this.logger.sendPerformanceEvent({
302
+ eventName: "ParallelRequests_Partial",
303
+ from: fromOrig,
304
+ to,
305
+ length,
306
+ });
307
+ }
308
+
309
+ if (to === this.latestRequested) {
310
+ // we can go after full chunk at the end if we received partial chunk, or more than asked
311
+ // Also if we got more than we asked to, we can actually use those ops!
312
+ if (payload.length !== 0) {
313
+ this.results.set(from, payload);
314
+ from += payload.length;
315
+ }
316
+
317
+ this.latestRequested = from;
318
+ fullChunk = true;
319
+ }
320
+
321
+ if (fullChunk) {
322
+ const chunk = this.getNextChunk();
323
+ if (chunk === undefined) {
324
+ break;
325
+ }
326
+ from = chunk.from;
327
+ to = chunk.to;
328
+ }
329
+ }
330
+ }
331
+ this.requestsInFlight--;
332
+ this.dispatch();
333
+ }
301
334
  }
302
335
 
303
336
  /**
@@ -305,45 +338,45 @@ export class ParallelRequests<T> {
305
338
  * It's essentially a pipe allowing multiple writers, and single reader
306
339
  */
307
340
  export class Queue<T> implements IStream<T> {
308
- private readonly queue: Promise<IStreamResult<T>>[] = [];
309
- private deferred: Deferred<IStreamResult<T>> | undefined;
310
- private done = false;
311
-
312
- public pushValue(value: T) {
313
- this.pushCore(Promise.resolve({ done: false, value }));
314
- }
315
-
316
- public pushError(error: any) {
317
- this.pushCore(Promise.reject(error));
318
- this.done = true;
319
- }
320
-
321
- public pushDone() {
322
- this.pushCore(Promise.resolve({ done: true }));
323
- this.done = true;
324
- }
325
-
326
- protected pushCore(value: Promise<IStreamResult<T>>) {
327
- assert(!this.done, 0x112 /* "cannot push onto queue if done" */);
328
- if (this.deferred) {
329
- assert(this.queue.length === 0, 0x113 /* "deferred queue should be empty" */);
330
- this.deferred.resolve(value);
331
- this.deferred = undefined;
332
- } else {
333
- this.queue.push(value);
334
- }
335
- }
336
-
337
- public async read(): Promise<IStreamResult<T>> {
338
- assert(this.deferred === undefined, 0x114 /* "cannot pop if deferred" */);
339
- const value = this.queue.shift();
340
- if (value !== undefined) {
341
- return value;
342
- }
343
- assert(!this.done, 0x115 /* "queue should not be done during pop" */);
344
- this.deferred = new Deferred<IStreamResult<T>>();
345
- return this.deferred.promise;
346
- }
341
+ private readonly queue: Promise<IStreamResult<T>>[] = [];
342
+ private deferred: Deferred<IStreamResult<T>> | undefined;
343
+ private done = false;
344
+
345
+ public pushValue(value: T) {
346
+ this.pushCore(Promise.resolve({ done: false, value }));
347
+ }
348
+
349
+ public pushError(error: any) {
350
+ this.pushCore(Promise.reject(error));
351
+ this.done = true;
352
+ }
353
+
354
+ public pushDone() {
355
+ this.pushCore(Promise.resolve({ done: true }));
356
+ this.done = true;
357
+ }
358
+
359
+ protected pushCore(value: Promise<IStreamResult<T>>) {
360
+ assert(!this.done, 0x112 /* "cannot push onto queue if done" */);
361
+ if (this.deferred) {
362
+ assert(this.queue.length === 0, 0x113 /* "deferred queue should be empty" */);
363
+ this.deferred.resolve(value);
364
+ this.deferred = undefined;
365
+ } else {
366
+ this.queue.push(value);
367
+ }
368
+ }
369
+
370
+ public async read(): Promise<IStreamResult<T>> {
371
+ assert(this.deferred === undefined, 0x114 /* "cannot pop if deferred" */);
372
+ const value = this.queue.shift();
373
+ if (value !== undefined) {
374
+ return value;
375
+ }
376
+ assert(!this.done, 0x115 /* "queue should not be done during pop" */);
377
+ this.deferred = new Deferred<IStreamResult<T>>();
378
+ return this.deferred.promise;
379
+ }
347
380
  }
348
381
 
349
382
  /**
@@ -360,93 +393,94 @@ export class Queue<T> implements IStream<T> {
360
393
  * @returns - an object with resulting ops and cancellation / partial result flags
361
394
  */
362
395
  async function getSingleOpBatch(
363
- get: (telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,
364
- props: ITelemetryProperties,
365
- strongTo: boolean,
366
- logger: ITelemetryLogger,
367
- signal?: AbortSignal,
368
- scenarioName?: string):
369
- Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[]; }> {
370
- let lastSuccessTime: number | undefined;
371
-
372
- let retry: number = 0;
373
- const deltas: ISequencedDocumentMessage[] = [];
374
- const nothing = { partial: false, cancel: true, payload: [] };
375
-
376
- while (signal?.aborted !== true) {
377
- retry++;
378
- let delay = Math.min(MaxFetchDelayInMs, MissingFetchDelayInMs * Math.pow(2, retry));
379
- const startTime = performance.now();
380
-
381
- try {
382
- // Issue async request for deltas - limit the number fetched to MaxBatchDeltas
383
- const deltasP = get({ ...props, retry } /* telemetry props */);
384
-
385
- const { messages, partialResult } = await deltasP;
386
- deltas.push(...messages);
387
-
388
- const deltasRetrievedLast = messages.length;
389
-
390
- if (deltasRetrievedLast !== 0 || !strongTo) {
391
- return { payload: deltas, cancel: false, partial: partialResult };
392
- }
393
-
394
- // Storage does not have ops we need.
395
- // Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry
396
- // count since something prevented us from seeing those deltas
397
-
398
- if (lastSuccessTime === undefined) {
399
- lastSuccessTime = performance.now();
400
- } else if (performance.now() - lastSuccessTime > 30000) {
401
- // If we are connected and receiving proper responses from server, but can't get any ops back,
402
- // then give up after some time. This likely indicates the issue with ordering service not flushing
403
- // ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get
404
- // current as it can't get ops.
405
- throw createGenericNetworkError(
406
- // pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries
407
- "Failed to retrieve ops from storage (Too Many Retries)",
408
- { canRetry: false },
409
- {
410
- retry,
411
- driverVersion,
412
- ...props,
413
- },
414
- );
415
- }
416
- } catch (error) {
417
- const canRetry = canRetryOnError(error);
418
-
419
- lastSuccessTime = undefined;
420
-
421
- const retryAfter = getRetryDelayFromError(error);
422
-
423
- // This will log to error table only if the error is non-retryable
424
- logNetworkFailure(
425
- logger,
426
- {
427
- eventName: "GetDeltas_Error",
428
- ...props,
429
- retry,
430
- duration: performance.now() - startTime,
431
- retryAfter,
432
- reason: scenarioName,
433
- },
434
- error);
435
-
436
- if (!canRetry) {
437
- // It's game over scenario.
438
- throw error;
439
- }
440
-
441
- if (retryAfter !== undefined && retryAfter >= 0) {
442
- delay = retryAfter;
443
- }
444
- }
445
-
446
- await waitForConnectedState(delay);
447
- }
448
-
449
- return nothing;
396
+ get: (telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,
397
+ props: ITelemetryProperties,
398
+ strongTo: boolean,
399
+ logger: ITelemetryLogger,
400
+ signal?: AbortSignal,
401
+ scenarioName?: string,
402
+ ): Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[] }> {
403
+ let lastSuccessTime: number | undefined;
404
+
405
+ let retry: number = 0;
406
+ const deltas: ISequencedDocumentMessage[] = [];
407
+ const nothing = { partial: false, cancel: true, payload: [] };
408
+
409
+ while (signal?.aborted !== true) {
410
+ retry++;
411
+ let delay = Math.min(MaxFetchDelayInMs, MissingFetchDelayInMs * Math.pow(2, retry));
412
+ const startTime = performance.now();
413
+
414
+ try {
415
+ // Issue async request for deltas - limit the number fetched to MaxBatchDeltas
416
+ const deltasP = get({ ...props, retry } /* telemetry props */);
417
+
418
+ const { messages, partialResult } = await deltasP;
419
+ deltas.push(...messages);
420
+
421
+ const deltasRetrievedLast = messages.length;
422
+
423
+ if (deltasRetrievedLast !== 0 || !strongTo) {
424
+ return { payload: deltas, cancel: false, partial: partialResult };
425
+ }
426
+
427
+ // Storage does not have ops we need.
428
+ // Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry
429
+ // count since something prevented us from seeing those deltas
430
+
431
+ if (lastSuccessTime === undefined) {
432
+ lastSuccessTime = performance.now();
433
+ } else if (performance.now() - lastSuccessTime > 30000) {
434
+ // If we are connected and receiving proper responses from server, but can't get any ops back,
435
+ // then give up after some time. This likely indicates the issue with ordering service not flushing
436
+ // ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get
437
+ // current as it can't get ops.
438
+ throw createGenericNetworkError(
439
+ // pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries
440
+ "Failed to retrieve ops from storage (Too Many Retries)",
441
+ { canRetry: false },
442
+ {
443
+ retry,
444
+ driverVersion,
445
+ ...props,
446
+ },
447
+ );
448
+ }
449
+ } catch (error) {
450
+ const canRetry = canRetryOnError(error);
451
+
452
+ lastSuccessTime = undefined;
453
+
454
+ const retryAfter = getRetryDelayFromError(error);
455
+
456
+ // This will log to error table only if the error is non-retryable
457
+ logNetworkFailure(
458
+ logger,
459
+ {
460
+ eventName: "GetDeltas_Error",
461
+ ...props,
462
+ retry,
463
+ duration: performance.now() - startTime,
464
+ retryAfter,
465
+ reason: scenarioName,
466
+ },
467
+ error,
468
+ );
469
+
470
+ if (!canRetry) {
471
+ // It's game over scenario.
472
+ throw error;
473
+ }
474
+
475
+ if (retryAfter !== undefined && retryAfter >= 0) {
476
+ delay = retryAfter;
477
+ }
478
+ }
479
+
480
+ await waitForConnectedState(delay);
481
+ }
482
+
483
+ return nothing;
450
484
  }
451
485
 
452
486
  /**
@@ -462,127 +496,155 @@ async function getSingleOpBatch(
462
496
  * @returns - Messages fetched
463
497
  */
464
498
  export function requestOps(
465
- get: (from: number, to: number, telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,
466
- concurrency: number,
467
- fromTotal: number,
468
- toTotal: number | undefined,
469
- payloadSize: number,
470
- logger: ITelemetryLogger,
471
- signal?: AbortSignal,
472
- scenarioName?: string,
499
+ get: (
500
+ from: number,
501
+ to: number,
502
+ telemetryProps: ITelemetryProperties,
503
+ ) => Promise<IDeltasFetchResult>,
504
+ concurrency: number,
505
+ fromTotal: number,
506
+ toTotal: number | undefined,
507
+ payloadSize: number,
508
+ logger: ITelemetryLogger,
509
+ signal?: AbortSignal,
510
+ scenarioName?: string,
473
511
  ): IStream<ISequencedDocumentMessage[]> {
474
- let requests = 0;
475
- let lastFetch: number | undefined;
476
- let length = 0;
477
- const queue = new Queue<ISequencedDocumentMessage[]>();
478
-
479
- const propsTotal: ITelemetryProperties = {
480
- fromTotal,
481
- toTotal,
482
- };
483
-
484
- const telemetryEvent = PerformanceEvent.start(logger, {
485
- eventName: "GetDeltas",
486
- ...propsTotal,
487
- reason: scenarioName,
488
- });
489
-
490
- const manager = new ParallelRequests<ISequencedDocumentMessage>(
491
- fromTotal,
492
- toTotal,
493
- payloadSize,
494
- logger,
495
- async (request: number, from: number, to: number, strongTo: boolean, propsPerRequest: ITelemetryProperties) => {
496
- requests++;
497
- return getSingleOpBatch(
498
- async (propsAll) => get(from, to, propsAll),
499
- { request, from, to, ...propsTotal, ...propsPerRequest },
500
- strongTo,
501
- logger,
502
- signal,
503
- scenarioName,
504
- );
505
- },
506
- (deltas: ISequencedDocumentMessage[]) => {
507
- // Assert continuing and right start.
508
- if (lastFetch === undefined) {
509
- assert(deltas[0].sequenceNumber === fromTotal, 0x26d /* "wrong start" */);
510
- } else {
511
- assert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* "wrong start" */);
512
- }
513
- lastFetch = deltas[deltas.length - 1].sequenceNumber;
514
- assert(lastFetch - deltas[0].sequenceNumber + 1 === deltas.length,
515
- 0x26f /* "continuous and no duplicates" */);
516
- length += deltas.length;
517
- queue.pushValue(deltas);
518
- });
519
-
520
- // Implement faster cancellation. getSingleOpBatch() checks signal, but only in between
521
- // waits (up to 10 seconds) and fetches (can take infinite amount of time).
522
- // While every such case should be improved and take into account signal (and thus cancel immediately),
523
- // it is beneficial to have catch-all
524
- const listener = (event: Event) => { manager.cancel(); };
525
- if (signal !== undefined) {
526
- signal.addEventListener("abort", listener);
527
- }
528
-
529
- manager.run(concurrency)
530
- .finally(() => {
531
- if (signal !== undefined) {
532
- signal.removeEventListener("abort", listener);
533
- }
534
- }).then(() => {
535
- const props = {
536
- lastFetch,
537
- length,
538
- requests,
539
- };
540
- if (manager.canceled) {
541
- telemetryEvent.cancel({ ...props, error: "ops request cancelled by client" });
542
- } else {
543
- assert(toTotal === undefined || lastFetch !== undefined && lastFetch >= toTotal - 1,
544
- 0x270 /* "All requested ops fetched" */);
545
- telemetryEvent.end(props);
546
- }
547
- queue.pushDone();
548
- })
549
- .catch((error) => {
550
- telemetryEvent.cancel({
551
- lastFetch,
552
- length,
553
- requests,
554
- }, error);
555
- queue.pushError(error);
556
- });
557
-
558
- return queue;
512
+ let requests = 0;
513
+ let lastFetch: number | undefined;
514
+ let length = 0;
515
+ const queue = new Queue<ISequencedDocumentMessage[]>();
516
+
517
+ const propsTotal: ITelemetryProperties = {
518
+ fromTotal,
519
+ toTotal,
520
+ };
521
+
522
+ const telemetryEvent = PerformanceEvent.start(logger, {
523
+ eventName: "GetDeltas",
524
+ ...propsTotal,
525
+ reason: scenarioName,
526
+ });
527
+
528
+ const manager = new ParallelRequests<ISequencedDocumentMessage>(
529
+ fromTotal,
530
+ toTotal,
531
+ payloadSize,
532
+ logger,
533
+ async (
534
+ request: number,
535
+ from: number,
536
+ to: number,
537
+ strongTo: boolean,
538
+ propsPerRequest: ITelemetryProperties,
539
+ ) => {
540
+ requests++;
541
+ return getSingleOpBatch(
542
+ async (propsAll) => get(from, to, propsAll),
543
+ { request, from, to, ...propsTotal, ...propsPerRequest },
544
+ strongTo,
545
+ logger,
546
+ signal,
547
+ scenarioName,
548
+ );
549
+ },
550
+ (deltas: ISequencedDocumentMessage[]) => {
551
+ // Assert continuing and right start.
552
+ if (lastFetch === undefined) {
553
+ assert(deltas[0].sequenceNumber === fromTotal, 0x26d /* "wrong start" */);
554
+ } else {
555
+ assert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* "wrong start" */);
556
+ }
557
+ lastFetch = deltas[deltas.length - 1].sequenceNumber;
558
+ assert(
559
+ lastFetch - deltas[0].sequenceNumber + 1 === deltas.length,
560
+ 0x26f /* "continuous and no duplicates" */,
561
+ );
562
+ length += deltas.length;
563
+ queue.pushValue(deltas);
564
+ },
565
+ );
566
+
567
+ // Implement faster cancellation. getSingleOpBatch() checks signal, but only in between
568
+ // waits (up to 10 seconds) and fetches (can take infinite amount of time).
569
+ // While every such case should be improved and take into account signal (and thus cancel immediately),
570
+ // it is beneficial to have catch-all
571
+ const listener = (event: Event) => {
572
+ manager.cancel();
573
+ };
574
+ if (signal !== undefined) {
575
+ signal.addEventListener("abort", listener);
576
+ }
577
+
578
+ manager
579
+ .run(concurrency)
580
+ .finally(() => {
581
+ if (signal !== undefined) {
582
+ signal.removeEventListener("abort", listener);
583
+ }
584
+ })
585
+ .then(() => {
586
+ const props = {
587
+ lastFetch,
588
+ length,
589
+ requests,
590
+ };
591
+ if (manager.canceled) {
592
+ telemetryEvent.cancel({ ...props, error: "ops request cancelled by client" });
593
+ } else {
594
+ assert(
595
+ toTotal === undefined || (lastFetch !== undefined && lastFetch >= toTotal - 1),
596
+ 0x270 /* "All requested ops fetched" */,
597
+ );
598
+ telemetryEvent.end(props);
599
+ }
600
+ queue.pushDone();
601
+ })
602
+ .catch((error) => {
603
+ telemetryEvent.cancel(
604
+ {
605
+ lastFetch,
606
+ length,
607
+ requests,
608
+ },
609
+ error,
610
+ );
611
+ queue.pushError(error);
612
+ });
613
+
614
+ return queue;
559
615
  }
560
616
 
561
617
  export const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {
562
- read: async () => { return { done: true }; },
618
+ read: async () => {
619
+ return { done: true };
620
+ },
563
621
  };
564
622
 
565
- export function streamFromMessages(messagesArg: Promise<ISequencedDocumentMessage[]>):
566
- IStream<ISequencedDocumentMessage[]> {
567
- let messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;
568
- return {
569
- read: async () => {
570
- if (messages === undefined) {
571
- return { done: true };
572
- }
573
- const value = await messages;
574
- messages = undefined;
575
- return value.length === 0 ? { done: true } : { done: false, value };
576
- },
577
- };
623
+ export function streamFromMessages(
624
+ messagesArg: Promise<ISequencedDocumentMessage[]>,
625
+ ): IStream<ISequencedDocumentMessage[]> {
626
+ let messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;
627
+ return {
628
+ read: async () => {
629
+ if (messages === undefined) {
630
+ return { done: true };
631
+ }
632
+ const value = await messages;
633
+ messages = undefined;
634
+ return value.length === 0 ? { done: true } : { done: false, value };
635
+ },
636
+ };
578
637
  }
579
638
 
580
- export function streamObserver<T>(stream: IStream<T>, handler: (value: IStreamResult<T>) => void): IStream<T> {
581
- return {
582
- read: async () => {
583
- const value = await stream.read();
584
- handler(value);
585
- return value;
586
- },
587
- };
639
+ export function streamObserver<T>(
640
+ stream: IStream<T>,
641
+ handler: (value: IStreamResult<T>) => void,
642
+ ): IStream<T> {
643
+ return {
644
+ read: async () => {
645
+ const value = await stream.read();
646
+ handler(value);
647
+ return value;
648
+ },
649
+ };
588
650
  }