Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions apps/provider-proxy/src/services/ProviderProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import https from "https";
import { LRUCache } from "lru-cache";
import { TLSSocket } from "tls";

import { propagateTracingContext } from "../utils/telemetry";
import type { CertificateValidator, CertValidationResultError } from "./CertificateValidator";

export class ProviderProxy {
Expand Down Expand Up @@ -38,7 +39,7 @@ export class ProviderProxy {
},
agent
},
async res => {
propagateTracingContext(async res => {
try {
const socket = res.socket;
if (!socket || !(socket instanceof TLSSocket)) {
Expand Down Expand Up @@ -75,19 +76,25 @@ export class ProviderProxy {
res.destroy();
resolve({ ok: false, code: "connectionError", error });
}
}
})
);

if (!req.reusedSocket) {
req.on("error", error => {
resolve({ ok: false, code: "connectionError", error });
});
req.on("timeout", () => {
// here we are just notified that response take more than specified in request options timeout
// then we manually destroy request and it drops connection and
// on('error') handler is called with Error code = ECONNRESET
req.destroy();
});
req.on(
"error",
propagateTracingContext(error => {
resolve({ ok: false, code: "connectionError", error });
})
);
req.on(
"timeout",
propagateTracingContext(() => {
// here we are just notified that response take more than specified in request options timeout
// then we manually destroy request and it drops connection and
// on('error') handler is called with Error code = ECONNRESET
req.destroy();
})
);
}

if (options.body && options.method !== "GET") req.write(options.body);
Expand Down