diff options
author | Jacob Hummer <jcbhmr@outlook.com> | 2023-11-10 22:43:30 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-11 10:13:30 +0530 |
commit | b2e3389a6aebe5378f49fa86391255f9fc8b0707 (patch) | |
tree | 11cda4746cd70bcb3c62b8b135ecd957424b5d6a | |
parent | eff3e432966f6bc9ed909ba22fcafc0978c924d7 (diff) |
fix(node/http): export globalAgent (#21081)
Fixes #21080
Fixes #18312
---------
Signed-off-by: Jacob Hummer <jcbhmr@outlook.com>
-rw-r--r-- | cli/tests/unit_node/http_test.ts | 24 | ||||
-rw-r--r-- | ext/node/polyfills/http.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/https.ts | 2 |
3 files changed, 27 insertions, 1 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts index ed52ccf13..84d25e42c 100644 --- a/cli/tests/unit_node/http_test.ts +++ b/cli/tests/unit_node/http_test.ts @@ -812,3 +812,27 @@ Deno.test( await server.finished; }, ); + +Deno.test("[node/http] node:http exports globalAgent", async () => { + const http = await import("node:http"); + assert( + http.globalAgent, + "node:http must export 'globalAgent' on module namespace", + ); + assert( + http.default.globalAgent, + "node:http must export 'globalAgent' on module default export", + ); +}); + +Deno.test("[node/https] node:https exports globalAgent", async () => { + const https = await import("node:https"); + assert( + https.globalAgent, + "node:https must export 'globalAgent' on module namespace", + ); + assert( + https.default.globalAgent, + "node:https must export 'globalAgent' on module default export", + ); +}); diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 78bd7cb07..4ad502760 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -1764,6 +1764,7 @@ export function get(...args: any[]) { export { Agent, ClientRequest, + globalAgent, IncomingMessageForServer as IncomingMessage, METHODS, OutgoingMessage, @@ -1771,6 +1772,7 @@ export { }; export default { Agent, + globalAgent, ClientRequest, STATUS_CODES, METHODS, diff --git a/ext/node/polyfills/https.ts b/ext/node/polyfills/https.ts index 46d4bd087..6cd42f035 100644 --- a/ext/node/polyfills/https.ts +++ b/ext/node/polyfills/https.ts @@ -104,7 +104,7 @@ export class Agent extends HttpAgent { } } -const globalAgent = new Agent({ +export const globalAgent = new Agent({ keepAlive: true, scheduling: "lifo", timeout: 5000, |