Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/cyan-worlds-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vercel/sandbox": patch
---

Reuse Undici `Agent` across instances
8 changes: 5 additions & 3 deletions packages/vercel-sandbox/src/api-client/base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface RequestParams extends RequestInit {
retry?: Partial<RetryOptions>;
}

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
Expand All @@ -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) {
Expand Down
Loading