Skip to content

Commit

Permalink
Destroy agent instances when disposed from cache (#350)
Browse files Browse the repository at this point in the history
Co-authored-by: Anna Henningsen <[email protected]>
  • Loading branch information
lukekarrys and addaleax authored Dec 5, 2024
1 parent a40e3ad commit ad68f63
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-vans-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'proxy-agent': patch
---

Dispose of Agent instances in cache correctly
5 changes: 4 additions & 1 deletion packages/proxy-agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export class ProxyAgent extends Agent {
/**
* Cache for `Agent` instances.
*/
cache = new LRUCache<string, Agent>({ max: 20 });
cache = new LRUCache<string, Agent>({
max: 20,
dispose: (agent) => agent.destroy(),
});

connectOpts?: ProxyAgentOptions;
httpAgent: http.Agent;
Expand Down
24 changes: 20 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ad68f63

Please sign in to comment.