fix(CosmosDB: http protocol endpoints no longer break CosmosClient (#31120)
### Packages impacted by this PR @azure/cosmos ### Issues associated with this PR #31119 ### Describe the problem that is addressed by this PR 1. "http:" protocol now works properly 2. Unhandled errors in tests now properly include stack trace in STDERR ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? We could possibly have done a further bifurcation of the logic for http: vs https:. I chose this design because it was a minimal change and maintains the original intent. ### Are there test cases added in this PR? _(If not, why?)_ No. There's not currently a good means to test http: against Cosmos DB, but that's a WIP. ### Provide a list of related PRs _(if any)_ N/A ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ N/A ### Checklists - [x] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - N/A - [ ] Added a changelog (if necessary) - N/A --------- Co-authored-by: Chris Anderson <andersonc@microsoft.com>
This commit is contained in:
Родитель
14bef3be43
Коммит
afde2d2838
|
@ -82,7 +82,8 @@ async function httpRequest(
|
|||
pipelineRequest.agent = requestContext.requestAgent;
|
||||
} else {
|
||||
const parsedUrl = new URL(url);
|
||||
pipelineRequest.agent = parsedUrl.protocol === "http" ? defaultHttpAgent : defaultHttpsAgent;
|
||||
pipelineRequest.agent = parsedUrl.protocol === "http:" ? defaultHttpAgent : defaultHttpsAgent;
|
||||
pipelineRequest.allowInsecureConnection = parsedUrl.protocol === "http:";
|
||||
}
|
||||
|
||||
const startTimeUTCInMs = getCurrentTimestampInMs();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
require("source-map-support").install();
|
||||
import util from "util";
|
||||
|
||||
process.on("unhandledRejection", (error: any) => {
|
||||
if (error.body) {
|
||||
|
@ -12,6 +13,9 @@ process.on("unhandledRejection", (error: any) => {
|
|||
/* NO OP */
|
||||
}
|
||||
}
|
||||
console.error(new Error("Unhandled exception found"));
|
||||
console.error(JSON.stringify(error, null, " "));
|
||||
const nestedError = new Error("Unhandled exception found");
|
||||
Object.defineProperty(nestedError, "errors", { value: [error] });
|
||||
console.error(
|
||||
util.formatWithOptions({ colors: true, compact: true, depth: 6 }, "%O", nestedError),
|
||||
);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче