@fluidframework/odsp-driver 2.0.0-dev-rc.4.0.0.261659 → 2.0.0-dev-rc.5.0.0.263932

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 (54) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/compactSnapshotParser.d.ts.map +1 -1
  3. package/dist/compactSnapshotParser.js +0 -5
  4. package/dist/compactSnapshotParser.js.map +1 -1
  5. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  6. package/dist/compactSnapshotWriter.js +0 -3
  7. package/dist/compactSnapshotWriter.js.map +1 -1
  8. package/dist/fetchSnapshot.d.ts.map +1 -1
  9. package/dist/fetchSnapshot.js +22 -2
  10. package/dist/fetchSnapshot.js.map +1 -1
  11. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  12. package/dist/odspDelayLoadedDeltaStream.js +11 -2
  13. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  14. package/dist/odspDocumentDeltaConnection.d.ts +1 -1
  15. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  16. package/dist/odspDocumentDeltaConnection.js +2 -1
  17. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  18. package/dist/odspError.d.ts.map +1 -1
  19. package/dist/odspError.js +5 -1
  20. package/dist/odspError.js.map +1 -1
  21. package/dist/packageVersion.d.ts +1 -1
  22. package/dist/packageVersion.js +1 -1
  23. package/dist/packageVersion.js.map +1 -1
  24. package/lib/compactSnapshotParser.d.ts.map +1 -1
  25. package/lib/compactSnapshotParser.js +0 -5
  26. package/lib/compactSnapshotParser.js.map +1 -1
  27. package/lib/compactSnapshotWriter.d.ts.map +1 -1
  28. package/lib/compactSnapshotWriter.js +0 -3
  29. package/lib/compactSnapshotWriter.js.map +1 -1
  30. package/lib/fetchSnapshot.d.ts.map +1 -1
  31. package/lib/fetchSnapshot.js +22 -2
  32. package/lib/fetchSnapshot.js.map +1 -1
  33. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  34. package/lib/odspDelayLoadedDeltaStream.js +11 -2
  35. package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
  36. package/lib/odspDocumentDeltaConnection.d.ts +1 -1
  37. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  38. package/lib/odspDocumentDeltaConnection.js +2 -1
  39. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  40. package/lib/odspError.d.ts.map +1 -1
  41. package/lib/odspError.js +5 -1
  42. package/lib/odspError.js.map +1 -1
  43. package/lib/packageVersion.d.ts +1 -1
  44. package/lib/packageVersion.js +1 -1
  45. package/lib/packageVersion.js.map +1 -1
  46. package/lib/tsdoc-metadata.json +1 -1
  47. package/package.json +14 -14
  48. package/src/compactSnapshotParser.ts +0 -9
  49. package/src/compactSnapshotWriter.ts +0 -4
  50. package/src/fetchSnapshot.ts +48 -20
  51. package/src/odspDelayLoadedDeltaStream.ts +14 -3
  52. package/src/odspDocumentDeltaConnection.ts +7 -3
  53. package/src/odspError.ts +5 -1
  54. package/src/packageVersion.ts +1 -1
@@ -375,17 +375,31 @@ async function fetchLatestSnapshotCore(
375
375
  case "application/json": {
376
376
  let text: string;
377
377
  [text, receiveContentTime] = await measureP(async () =>
378
- odspResponse.content.text().catch((error) =>
379
- // Parsing can fail and message could contain full request URI, including
380
- // tokens, etc. So do not log error object itself.
381
- throwOdspNetworkError(
382
- "Error while parsing fetch response",
383
- fetchIncorrectResponse,
384
- odspResponse.content, // response
385
- undefined, // response text
386
- propsToLog,
378
+ odspResponse.content
379
+ .text()
380
+ .then((res) => {
381
+ if (res.length === 0) {
382
+ throwOdspNetworkError(
383
+ "Response from browser is empty",
384
+ fetchIncorrectResponse,
385
+ odspResponse.content, // response
386
+ undefined, // response text
387
+ propsToLog,
388
+ );
389
+ }
390
+ return res;
391
+ })
392
+ .catch((error) =>
393
+ // Parsing can fail and message could contain full request URI, including
394
+ // tokens, etc. So do not log error object itself.
395
+ throwOdspNetworkError(
396
+ "Error while parsing fetch response",
397
+ fetchIncorrectResponse,
398
+ odspResponse.content, // response
399
+ undefined, // response text
400
+ propsToLog,
401
+ ),
387
402
  ),
388
- ),
389
403
  );
390
404
  propsToLog.bodySize = text.length;
391
405
  let content: IOdspSnapshot;
@@ -405,17 +419,31 @@ async function fetchLatestSnapshotCore(
405
419
  case "application/ms-fluid": {
406
420
  let content: ArrayBuffer;
407
421
  [content, receiveContentTime] = await measureP(async () =>
408
- odspResponse.content.arrayBuffer().catch((error) =>
409
- // Parsing can fail and message could contain full request URI, including
410
- // tokens, etc. So do not log error object itself.
411
- throwOdspNetworkError(
412
- "Error while parsing fetch response",
413
- fetchIncorrectResponse,
414
- odspResponse.content, // response
415
- undefined, // response text
416
- propsToLog,
422
+ odspResponse.content
423
+ .arrayBuffer()
424
+ .then((res) => {
425
+ if (res.byteLength === 0) {
426
+ throwOdspNetworkError(
427
+ "Response from browser is empty",
428
+ fetchIncorrectResponse,
429
+ odspResponse.content, // response
430
+ undefined, // response text
431
+ propsToLog,
432
+ );
433
+ }
434
+ return res;
435
+ })
436
+ .catch((error) =>
437
+ // Parsing can fail and message could contain full request URI, including
438
+ // tokens, etc. So do not log error object itself.
439
+ throwOdspNetworkError(
440
+ "Error while parsing fetch response",
441
+ fetchIncorrectResponse,
442
+ odspResponse.content, // response
443
+ undefined, // response text
444
+ propsToLog,
445
+ ),
417
446
  ),
418
- ),
419
447
  );
420
448
  propsToLog.bodySize = content.byteLength;
421
449
  let snapshotContents: ISnapshotContentsWithProps;
@@ -10,6 +10,7 @@ import {
10
10
  IDocumentDeltaConnection,
11
11
  IDocumentServicePolicies,
12
12
  IResolvedUrl,
13
+ type IAnyDriverError,
13
14
  } from "@fluidframework/driver-definitions/internal";
14
15
  import {
15
16
  DeltaStreamConnectionForbiddenError,
@@ -220,9 +221,19 @@ export class OdspDelayLoadedDeltaStream {
220
221
  this.currentConnection = connection;
221
222
  return connection;
222
223
  } catch (error) {
223
- this.clearJoinSessionTimer();
224
- this.cache.sessionJoinCache.remove(this.joinSessionKey);
225
-
224
+ // Remove join session information from cache only if it is an error is from socket event connect_document_error.
225
+ // Otherwise keep it in cache so that this session can be re-used after disconnection.
226
+ // Also keeping an undefined check here to account for any unknown code path that is unable to stamp the value as in that case also
227
+ // it is safer to clear join session cache and start over.
228
+ if (
229
+ error &&
230
+ typeof error === "object" &&
231
+ ((error as IAnyDriverError).scenarioName === "connect_document_error" ||
232
+ (error as IAnyDriverError).scenarioName === undefined)
233
+ ) {
234
+ this.clearJoinSessionTimer();
235
+ this.cache.sessionJoinCache.remove(this.joinSessionKey);
236
+ }
226
237
  const normalizedError = this.annotateConnectionError(
227
238
  error,
228
239
  "createDeltaConnection",
@@ -7,7 +7,7 @@ import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
7
7
  import { IEvent } from "@fluidframework/core-interfaces";
8
8
  import { assert, Deferred } from "@fluidframework/core-utils/internal";
9
9
  import { DocumentDeltaConnection } from "@fluidframework/driver-base/internal";
10
- import { IAnyDriverError } from "@fluidframework/driver-definitions";
10
+ import { IAnyDriverError } from "@fluidframework/driver-definitions/internal";
11
11
  import { createGenericNetworkError } from "@fluidframework/driver-utils/internal";
12
12
  import { OdspError } from "@fluidframework/odsp-driver-definitions/internal";
13
13
  import {
@@ -361,8 +361,12 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
361
361
  /**
362
362
  * Error raising for socket.io issues
363
363
  */
364
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
365
- protected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {
364
+ protected createErrorObject(
365
+ handler: string,
366
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
367
+ error?: any,
368
+ canRetry = true,
369
+ ): IAnyDriverError {
366
370
  // Note: we suspect the incoming error object is either:
367
371
  // - a socketError: add it to the OdspError object for driver to be able to parse it and reason over it.
368
372
  // - anything else: let base class handle it
package/src/odspError.ts CHANGED
@@ -32,7 +32,11 @@ export function errorObjectFromSocketError(
32
32
  : undefined, // responseText
33
33
  );
34
34
 
35
- error.addTelemetryProperties({ odspError: true, relayServiceError: true });
35
+ error.addTelemetryProperties({
36
+ odspError: true,
37
+ relayServiceError: true,
38
+ scenarioName: handler,
39
+ });
36
40
  return error;
37
41
  } catch {
38
42
  return new NonRetryableError(
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/odsp-driver";
9
- export const pkgVersion = "2.0.0-dev-rc.4.0.0.261659";
9
+ export const pkgVersion = "2.0.0-dev-rc.5.0.0.263932";