Skip to content

Commit

Permalink
fix(node/http): export globalAgent (#21081)
Browse files Browse the repository at this point in the history
Fixes #21080 
Fixes #18312

---------

Signed-off-by: Jacob Hummer <[email protected]>
  • Loading branch information
jcbhmr authored and kt3k committed Nov 17, 2023
1 parent 407230f commit f155ca7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions cli/tests/unit_node/http_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
});
2 changes: 2 additions & 0 deletions ext/node/polyfills/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1764,13 +1764,15 @@ export function get(...args: any[]) {
export {
Agent,
ClientRequest,
globalAgent,
IncomingMessageForServer as IncomingMessage,
METHODS,
OutgoingMessage,
STATUS_CODES,
};
export default {
Agent,
globalAgent,
ClientRequest,
STATUS_CODES,
METHODS,
Expand Down
2 changes: 1 addition & 1 deletion ext/node/polyfills/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class Agent extends HttpAgent {
}
}

const globalAgent = new Agent({
export const globalAgent = new Agent({
keepAlive: true,
scheduling: "lifo",
timeout: 5000,
Expand Down

0 comments on commit f155ca7

Please sign in to comment.