From 369bd3d57dff4f49d34243dd0bb6122aee01ec24 Mon Sep 17 00:00:00 2001 From: Tom Lienard Date: Fri, 10 Apr 2026 10:25:38 +0100 Subject: [PATCH 1/2] perf(sdk): re-use Undici `Agent` across instances --- packages/vercel-sandbox/src/api-client/base-client.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/vercel-sandbox/src/api-client/base-client.ts b/packages/vercel-sandbox/src/api-client/base-client.ts index 172da716..42f83424 100644 --- a/packages/vercel-sandbox/src/api-client/base-client.ts +++ b/packages/vercel-sandbox/src/api-client/base-client.ts @@ -13,6 +13,10 @@ export interface RequestParams extends RequestInit { retry?: Partial; } +const DEFAULT_AGENT = new Agent({ + bodyTimeout: 0, // disable body timeout to allow long logs streaming +}); + /** * A base API client that provides a convenience wrapper for fetching where * we can pass query parameters as an object, support retries, debugging @@ -35,9 +39,7 @@ export class BaseClient { this.baseUrl = params.baseUrl; this.debug = params.debug ?? process.env.DEBUG_FETCH === "true"; this.token = params.token; - this.agent = new Agent({ - bodyTimeout: 0, // disable body timeout to allow long logs streaming - }); + this.agent = DEFAULT_AGENT; } protected async request(path: string, opts?: RequestParams) { From 6216248c4761928288e18a4669e377163eda09ef Mon Sep 17 00:00:00 2001 From: Tom Lienard Date: Fri, 10 Apr 2026 10:27:19 +0100 Subject: [PATCH 2/2] Add changeset --- .changeset/cyan-worlds-work.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/cyan-worlds-work.md diff --git a/.changeset/cyan-worlds-work.md b/.changeset/cyan-worlds-work.md new file mode 100644 index 00000000..467198ba --- /dev/null +++ b/.changeset/cyan-worlds-work.md @@ -0,0 +1,5 @@ +--- +"@vercel/sandbox": patch +--- + +Reuse Undici `Agent` across instances