@fluidframework/odsp-driver 0.52.1 → 0.53.0-46105
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.
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createFile.js +5 -4
- package/dist/createFile.js.map +1 -1
- package/dist/epochTracker.d.ts +2 -1
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +50 -21
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +15 -14
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.js +3 -3
- package/dist/getFileLink.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts +3 -3
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +7 -4
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +2 -0
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +3 -3
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +29 -26
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +4 -3
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspError.d.ts.map +1 -1
- package/dist/odspError.js +3 -1
- package/dist/odspError.js.map +1 -1
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +31 -22
- package/dist/odspUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +3 -3
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/createFile.d.ts.map +1 -1
- package/lib/createFile.js +6 -5
- package/lib/createFile.js.map +1 -1
- package/lib/epochTracker.d.ts +2 -1
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +50 -21
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +15 -14
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.js +4 -4
- package/lib/getFileLink.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts +3 -3
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +7 -4
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +2 -0
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +4 -4
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +31 -28
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +5 -4
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspError.d.ts.map +1 -1
- package/lib/odspError.js +3 -1
- package/lib/odspError.js.map +1 -1
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +33 -24
- package/lib/odspUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +3 -3
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +8 -8
- package/src/createFile.ts +13 -9
- package/src/epochTracker.ts +50 -20
- package/src/fetchSnapshot.ts +15 -8
- package/src/getFileLink.ts +10 -4
- package/src/odspDeltaStorageService.ts +10 -3
- package/src/odspDocumentDeltaConnection.ts +2 -0
- package/src/odspDocumentService.ts +8 -4
- package/src/odspDocumentStorageManager.ts +48 -28
- package/src/odspDriverUrlResolverForShareLink.ts +8 -3
- package/src/odspError.ts +5 -1
- package/src/odspUtils.ts +43 -34
- package/src/packageVersion.ts +1 -1
- package/src/zipItDataRepresentationUtils.ts +4 -7
|
@@ -7,7 +7,7 @@ import { PromiseCache } from "@fluidframework/common-utils";
|
|
|
7
7
|
import { IFluidCodeDetails, IRequest, isFluidPackage } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
|
|
9
9
|
import { ITelemetryBaseLogger, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
10
|
-
import {
|
|
10
|
+
import { NonRetryableError } from "@fluidframework/driver-utils";
|
|
11
11
|
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
12
12
|
import {
|
|
13
13
|
IOdspResolvedUrl,
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
isTokenFromCache,
|
|
16
16
|
OdspResourceTokenFetchOptions,
|
|
17
17
|
TokenFetcher,
|
|
18
|
+
OdspErrorType,
|
|
18
19
|
} from "@fluidframework/odsp-driver-definitions";
|
|
19
20
|
import {
|
|
20
21
|
getLocatorFromOdspUrl,
|
|
@@ -132,8 +133,9 @@ export class OdspDriverUrlResolverForShareLink implements IUrlResolver {
|
|
|
132
133
|
// We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId
|
|
133
134
|
// when redeeming the share link during the redeem fallback for trees latest call becomes greater than
|
|
134
135
|
// the eligible length.
|
|
136
|
+
odspResolvedUrl.sharingLinkToRedeem = this.removeNavParam(request.url);
|
|
135
137
|
odspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo || {},
|
|
136
|
-
{sharingLinkToRedeem:
|
|
138
|
+
{sharingLinkToRedeem: odspResolvedUrl.sharingLinkToRedeem});
|
|
137
139
|
}
|
|
138
140
|
if (odspResolvedUrl.itemId) {
|
|
139
141
|
// Kick start the sharing link request if we don't have it already as a performance optimization.
|
|
@@ -161,7 +163,10 @@ export class OdspDriverUrlResolverForShareLink implements IUrlResolver {
|
|
|
161
163
|
{ eventName: "GetSharingLinkToken" },
|
|
162
164
|
async (event) => tokenFetcher(options).then((tokenResponse) => {
|
|
163
165
|
if (tokenResponse === null) {
|
|
164
|
-
|
|
166
|
+
throw new NonRetryableError(
|
|
167
|
+
"shareLinkTokenIsNull",
|
|
168
|
+
"Token callback returned null",
|
|
169
|
+
OdspErrorType.fetchTokenError);
|
|
165
170
|
}
|
|
166
171
|
event.end({ fromCache: isTokenFromCache(tokenResponse) });
|
|
167
172
|
return tokenResponse;
|
package/src/odspError.ts
CHANGED
|
@@ -11,9 +11,13 @@ import { IOdspSocketError } from "./contracts";
|
|
|
11
11
|
*/
|
|
12
12
|
export function errorObjectFromSocketError(socketError: IOdspSocketError, handler: string) {
|
|
13
13
|
const message = `OdspSocketError (${handler}): ${socketError.message}`;
|
|
14
|
-
|
|
14
|
+
const error = createOdspNetworkError(
|
|
15
15
|
`odspSocketError [${handler}]`,
|
|
16
16
|
message,
|
|
17
17
|
socketError.code,
|
|
18
18
|
socketError.retryAfter);
|
|
19
|
+
|
|
20
|
+
error.addTelemetryProperties({ odspError: true, relayServiceError: true });
|
|
21
|
+
|
|
22
|
+
return error;
|
|
19
23
|
}
|
package/src/odspUtils.ts
CHANGED
|
@@ -5,19 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import { ITelemetryProperties, ITelemetryBaseLogger, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
7
|
import { IResolvedUrl, DriverErrorType } from "@fluidframework/driver-definitions";
|
|
8
|
-
import { isOnline, OnlineStatus } from "@fluidframework/driver-utils";
|
|
8
|
+
import { isOnline, OnlineStatus, RetryableError, NonRetryableError } from "@fluidframework/driver-utils";
|
|
9
9
|
import { assert, performance } from "@fluidframework/common-utils";
|
|
10
10
|
import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
11
11
|
import { ChildLogger, PerformanceEvent, wrapError } from "@fluidframework/telemetry-utils";
|
|
12
12
|
import {
|
|
13
13
|
fetchIncorrectResponse,
|
|
14
|
-
offlineFetchFailureStatusCode,
|
|
15
|
-
fetchFailureStatusCode,
|
|
16
|
-
fetchTimeoutStatusCode,
|
|
17
14
|
throwOdspNetworkError,
|
|
18
15
|
getSPOAndGraphRequestIdsFromResponse,
|
|
19
|
-
fetchTokenErrorCode,
|
|
20
|
-
createOdspNetworkError,
|
|
21
16
|
} from "@fluidframework/odsp-doclib-utils";
|
|
22
17
|
import {
|
|
23
18
|
IOdspResolvedUrl,
|
|
@@ -82,7 +77,7 @@ export async function getWithRetryForTokenRefresh<T>(get: (options: TokenFetchOp
|
|
|
82
77
|
case DriverErrorType.authorizationError:
|
|
83
78
|
return get({ ...options, claims: e.claims, tenantId: e.tenantId });
|
|
84
79
|
|
|
85
|
-
case DriverErrorType.incorrectServerResponse: //
|
|
80
|
+
case DriverErrorType.incorrectServerResponse: // some error on the wire, retry once
|
|
86
81
|
case OdspErrorType.fetchTokenError: // If the token was null, then retry once.
|
|
87
82
|
return get(options);
|
|
88
83
|
|
|
@@ -107,7 +102,10 @@ export async function fetchHelper(
|
|
|
107
102
|
const response = fetchResponse as any as Response;
|
|
108
103
|
// Let's assume we can retry.
|
|
109
104
|
if (!response) {
|
|
110
|
-
|
|
105
|
+
throw new NonRetryableError(
|
|
106
|
+
"odspFetchErrorNoResponse",
|
|
107
|
+
"No response from fetch call",
|
|
108
|
+
DriverErrorType.incorrectServerResponse);
|
|
111
109
|
}
|
|
112
110
|
if (!response.ok || response.status < 200 || response.status >= 300) {
|
|
113
111
|
throwOdspNetworkError(
|
|
@@ -130,11 +128,13 @@ export async function fetchHelper(
|
|
|
130
128
|
if (errorText === "TypeError: Failed to fetch") {
|
|
131
129
|
online = OnlineStatus.Offline;
|
|
132
130
|
}
|
|
131
|
+
// This error is thrown by fetch() when AbortSignal is provided and it gets cancelled
|
|
133
132
|
if (error.name === "AbortError") {
|
|
134
|
-
|
|
133
|
+
throw new RetryableError("fetchAbort", "Fetch Timeout (AbortError)", OdspErrorType.fetchTimeout);
|
|
135
134
|
}
|
|
135
|
+
// TCP/IP timeout
|
|
136
136
|
if (errorText.indexOf("ETIMEDOUT") !== -1) {
|
|
137
|
-
|
|
137
|
+
throw new RetryableError("fetchETimedout", "Fetch Timeout (ETIMEDOUT)", OdspErrorType.fetchTimeout);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
//
|
|
@@ -142,11 +142,11 @@ export async function fetchHelper(
|
|
|
142
142
|
// It could container PII, like URI in message itself, or token in properties.
|
|
143
143
|
// It is also non-serializable object due to circular references.
|
|
144
144
|
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
if (online === OnlineStatus.Offline) {
|
|
146
|
+
throw new RetryableError("OdspFetchOffline", `Offline: ${errorText}`, DriverErrorType.offlineError);
|
|
147
|
+
} else {
|
|
148
|
+
throw new RetryableError("OdspFetchError", `Fetch error: ${errorText}`, DriverErrorType.fetchFailure);
|
|
149
|
+
}
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -181,30 +181,31 @@ export async function fetchAndParseAsJSONHelper<T>(
|
|
|
181
181
|
requestInit: RequestInit | undefined,
|
|
182
182
|
): Promise<IOdspResponse<T>> {
|
|
183
183
|
const { content, headers, commonSpoHeaders, duration } = await fetchHelper(requestInfo, requestInit);
|
|
184
|
-
|
|
185
|
-
// tokens... It fails for me with "Unexpected end of JSON input" quite often - an attempt to download big file
|
|
186
|
-
// (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always
|
|
187
|
-
// succeeds on retry.
|
|
184
|
+
let text: string | undefined;
|
|
188
185
|
try {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
commonSpoHeaders.bodySize = text.length;
|
|
192
|
-
const res = {
|
|
193
|
-
headers,
|
|
194
|
-
content: JSON.parse(text),
|
|
195
|
-
commonSpoHeaders,
|
|
196
|
-
duration,
|
|
197
|
-
};
|
|
198
|
-
return res;
|
|
186
|
+
text = await content.text();
|
|
199
187
|
} catch (e) {
|
|
188
|
+
// JSON.parse() can fail and message would container full request URI, including
|
|
189
|
+
// tokens... It fails for me with "Unexpected end of JSON input" quite often - an attempt to download big file
|
|
190
|
+
// (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always
|
|
191
|
+
// succeeds on retry.
|
|
192
|
+
// So do not log error object itself.
|
|
200
193
|
throwOdspNetworkError(
|
|
201
194
|
"errorWhileParsingFetchResponse",
|
|
202
195
|
fetchIncorrectResponse,
|
|
203
|
-
content,
|
|
204
|
-
|
|
205
|
-
{ error: Object(e) },
|
|
196
|
+
content, // response
|
|
197
|
+
text,
|
|
206
198
|
);
|
|
207
199
|
}
|
|
200
|
+
|
|
201
|
+
commonSpoHeaders.bodySize = text.length;
|
|
202
|
+
const res = {
|
|
203
|
+
headers,
|
|
204
|
+
content: JSON.parse(text),
|
|
205
|
+
commonSpoHeaders,
|
|
206
|
+
duration,
|
|
207
|
+
};
|
|
208
|
+
return res;
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
export interface INewFileInfo {
|
|
@@ -293,13 +294,21 @@ export function toInstrumentedOdspTokenFetcher(
|
|
|
293
294
|
event.end({ fromCache: isTokenFromCache(tokenResponse), isNull: token === null });
|
|
294
295
|
}
|
|
295
296
|
if (token === null && throwOnNullToken) {
|
|
296
|
-
|
|
297
|
+
throw new NonRetryableError(
|
|
298
|
+
"storageTokenIsNull",
|
|
299
|
+
`Token is null for ${name} call`,
|
|
300
|
+
OdspErrorType.fetchTokenError,
|
|
301
|
+
{ method: name });
|
|
297
302
|
}
|
|
298
303
|
return token;
|
|
299
304
|
}, (error) => {
|
|
300
305
|
const tokenError = wrapError(
|
|
301
306
|
error,
|
|
302
|
-
(errorMessage) =>
|
|
307
|
+
(errorMessage) => new NonRetryableError(
|
|
308
|
+
"tokenFetcherFailed",
|
|
309
|
+
errorMessage,
|
|
310
|
+
OdspErrorType.fetchTokenError,
|
|
311
|
+
{ method: name }));
|
|
303
312
|
throw tokenError;
|
|
304
313
|
}),
|
|
305
314
|
{ cancel: "generic" });
|
package/src/packageVersion.ts
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { assert, IsoBuffer, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from "@fluidframework/common-utils";
|
|
12
|
-
import {
|
|
12
|
+
import { NonRetryableError } from "@fluidframework/driver-utils";
|
|
13
|
+
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
13
14
|
import { ReadBuffer } from "./ReadBufferUtils";
|
|
14
15
|
|
|
15
16
|
// eslint-disable-next-line max-len
|
|
@@ -477,18 +478,14 @@ function throwBufferParseException(
|
|
|
477
478
|
expectedNodeType: NodeType,
|
|
478
479
|
message: string,
|
|
479
480
|
): never {
|
|
480
|
-
|
|
481
|
+
throw new NonRetryableError(
|
|
481
482
|
"bufferParsingException",
|
|
482
483
|
message,
|
|
483
|
-
|
|
484
|
-
undefined,
|
|
485
|
-
undefined,
|
|
486
|
-
undefined,
|
|
484
|
+
DriverErrorType.incorrectServerResponse,
|
|
487
485
|
{
|
|
488
486
|
nodeType: getNodeType(node),
|
|
489
487
|
expectedNodeType,
|
|
490
488
|
});
|
|
491
|
-
throw error;
|
|
492
489
|
}
|
|
493
490
|
|
|
494
491
|
function getNodeType(value: NodeTypes): NodeType {
|