@azure/cosmos
Advanced tools
Comparing version 4.2.1-alpha.20250127.1 to 4.2.1-alpha.20250128.3
@@ -326,10 +326,11 @@ import { __asyncGenerator, __await } from "tslib"; | ||
catch (err) { | ||
if (err.code >= StatusCodes.BadRequest && err.code !== StatusCodes.Gone) { | ||
const errorResponse = new ErrorResponse(err.message); | ||
errorResponse.code = err.code; | ||
errorResponse.headers = err.headers; | ||
throw errorResponse; | ||
// If partition split/merge is encountered, handle it gracefully and continue fetching results. | ||
if (err.code === StatusCodes.Gone) { | ||
return new ChangeFeedIteratorResponse([], 0, err.code, err.headers, getEmptyCosmosDiagnostics(), err.substatus); | ||
} | ||
// If any other errors are encountered, eg. partition split or gone, handle it based on error code and not break the flow. | ||
return new ChangeFeedIteratorResponse([], 0, err.code, err.headers, getEmptyCosmosDiagnostics(), err.substatus); | ||
// If any other errors are encountered, throw the error. | ||
const errorResponse = new ErrorResponse(err.message); | ||
errorResponse.code = err.code; | ||
errorResponse.headers = err.headers; | ||
throw errorResponse; | ||
} | ||
@@ -336,0 +337,0 @@ } |
import { __asyncGenerator, __await } from "tslib"; | ||
import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; | ||
import { Constants, ResourceType, StatusCodes } from "../../common"; | ||
import { Constants, ResourceType } from "../../common"; | ||
import { ErrorResponse } from "../../request"; | ||
@@ -142,9 +142,7 @@ import { ContinuationTokenForPartitionKey } from "./ContinuationTokenForPartitionKey"; | ||
catch (err) { | ||
if (err.code >= StatusCodes.BadRequest && err.code !== StatusCodes.Gone) { | ||
const errorResponse = new ErrorResponse(err.message); | ||
errorResponse.code = err.code; | ||
errorResponse.headers = err.headers; | ||
throw errorResponse; | ||
} | ||
return new ChangeFeedIteratorResponse([], 0, err.code, err.headers, getEmptyCosmosDiagnostics()); | ||
// If any errors are encountered, throw the error. | ||
const errorResponse = new ErrorResponse(err.message); | ||
errorResponse.code = err.code; | ||
errorResponse.headers = err.headers; | ||
throw errorResponse; | ||
} | ||
@@ -151,0 +149,0 @@ } |
@@ -97,3 +97,3 @@ // Copyright (c) Microsoft Corporation. | ||
// Request header to tell backend to give you index metrics. | ||
PopulateIndexMetrics: "x-ms-cosmos-populateindexmetrics", | ||
PopulateIndexMetrics: "x-ms-cosmos-populateindexmetrics-V2", | ||
// Response header that holds the serialized version of index metrics. | ||
@@ -100,0 +100,0 @@ IndexUtilization: "x-ms-cosmos-index-utilization", |
@@ -14,2 +14,4 @@ export interface CosmosHeaders { | ||
export declare function mergeHeaders(headers: CosmosHeaders, toBeMergedHeaders: CosmosHeaders): void; | ||
/** @hidden */ | ||
export declare function decodeAndParseJSONString(inputString: string): string; | ||
//# sourceMappingURL=headerUtils.d.ts.map |
@@ -79,2 +79,17 @@ // Copyright (c) Microsoft Corporation. | ||
} | ||
/** @hidden */ | ||
export function decodeAndParseJSONString(inputString) { | ||
try { | ||
if (!inputString || inputString === "") { | ||
return "{}"; | ||
} | ||
const decodedString = decodeURIComponent(inputString); | ||
const parsedString = JSON.parse(decodedString); | ||
const indexMetrics = JSON.stringify(parsedString); | ||
return indexMetrics; | ||
} | ||
catch (e) { | ||
console.error("Error parsing JSON file:", e.message); | ||
} | ||
} | ||
//# sourceMappingURL=headerUtils.js.map |
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
import { Constants } from "../common"; | ||
import { getRequestChargeIfAny } from "../queryExecutionContext/headerUtils"; | ||
import { IndexMetricWriter, IndexUtilizationInfo } from "../indexMetrics"; | ||
import { decodeAndParseJSONString, getRequestChargeIfAny, } from "../queryExecutionContext/headerUtils"; | ||
export class FeedResponse { | ||
@@ -32,7 +31,5 @@ constructor(resources, headers, hasMoreResults, diagnostics) { | ||
get indexMetrics() { | ||
const writer = new IndexMetricWriter(); | ||
const indexUtilizationInfo = IndexUtilizationInfo.createFromString(this.headers[Constants.HttpHeaders.IndexUtilization], true); | ||
return writer.writeIndexMetrics(indexUtilizationInfo); | ||
return decodeAndParseJSONString(this.headers[Constants.HttpHeaders.IndexUtilization]); | ||
} | ||
} | ||
//# sourceMappingURL=FeedResponse.js.map |
{ | ||
"name": "@azure/cosmos", | ||
"version": "4.2.1-alpha.20250127.1", | ||
"version": "4.2.1-alpha.20250128.3", | ||
"description": "Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API", | ||
@@ -75,3 +75,3 @@ "sdk-type": "client", | ||
"unit-test:browser": "echo skipped", | ||
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 100000 './test/internal/unit/*.spec.ts'", | ||
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 100000 './test/internal/unit/**/*.spec.ts'", | ||
"update-snippets": "echo skipped" | ||
@@ -78,0 +78,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
4140124
1032
38058