Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Silence undici fallback warning (#1375)
Matt Brockmanb7fa99e2b738
diff --git a/.changeset/silence-undici-fallback-warning.md b/.changeset/silence-undici-fallback-warning.mdnew file mode 100644index 000000000..fc541bade--- /dev/null+++ b/.changeset/silence-undici-fallback-warning.md@@ -0,0 +1,5 @@+---+"e2b": patch+---++Silence the undici HTTP/2 fallback warning.diff --git a/packages/js-sdk/src/api/http2.ts b/packages/js-sdk/src/api/http2.tsindex bb5e54602..7bc4b92da 100644--- a/packages/js-sdk/src/api/http2.ts+++ b/packages/js-sdk/src/api/http2.ts@@ -12,11 +12,8 @@ const DEFAULT_API_CONNECTION_LIMIT = 100// 1000 = ~10 streams per connection (with the 100-conn default).// Override via env if your workload needs different.const DEFAULT_API_INFLIGHT_LIMIT = 1000-const API_UNDICI_FALLBACK_WARNING =- 'Failed to load undici for API HTTP/2 transport; falling back to global fetch.'let apiFetch: typeof fetch | undefined-let hasWarnedUndiciFallback = falseexport function createApiFetch(): typeof fetch {if (apiFetch) {@@ -59,8 +56,6 @@ async function buildApiFetcher(options: {const inflightLimit = options.inflightLimit ?? getApiInflightLimit()if (!undici) {- warnUndiciFallback()-return limitConcurrency(fetch, inflightLimit)}@@ -106,12 +101,3 @@ export function getApiInflightLimit(): number {DEFAULT_API_INFLIGHT_LIMIT)}--function warnUndiciFallback() {- if (hasWarnedUndiciFallback) {- return- }-- hasWarnedUndiciFallback = true- console.warn(API_UNDICI_FALLBACK_WARNING)-}diff --git a/packages/js-sdk/src/envd/http2.ts b/packages/js-sdk/src/envd/http2.tsindex 0b2bda119..0ddf59747 100644--- a/packages/js-sdk/src/envd/http2.ts+++ b/packages/js-sdk/src/envd/http2.ts@@ -16,7 +16,6 @@ type EnvdFetchOptions = {let envdFetch: typeof fetch | undefinedlet envdRpcFetch: typeof fetch | undefined-let hasWarnedUndiciFallback = falseconst DEFAULT_ENVD_CONNECTION_LIMIT = 10const DEFAULT_ENVD_RPC_CONNECTION_LIMIT = 200const DEFAULT_ENVD_INFLIGHT_LIMIT = 2000@@ -47,8 +46,6 @@ async function buildEnvdFetcher(const inflightLimit = options.inflightLimit ?? 0if (!undici) {- warnUndiciFallback()-return limitConcurrency(fetch, inflightLimit)}@@ -76,17 +73,6 @@ async function buildEnvdFetcher(return limitConcurrency(wrapped, inflightLimit)}-function warnUndiciFallback() {- if (hasWarnedUndiciFallback) {- return- }-- hasWarnedUndiciFallback = true- console.warn(- 'Failed to load undici for envd HTTP/2 transport; falling back to global fetch.'- )-}-export function createEnvdFetch(): typeof fetch {if (envdFetch) {return envdFetchdiff --git a/packages/js-sdk/tests/envd/http2.test.ts b/packages/js-sdk/tests/envd/http2.test.tsindex 8e4e7eef5..fc8bfc40d 100644--- a/packages/js-sdk/tests/envd/http2.test.ts+++ b/packages/js-sdk/tests/envd/http2.test.ts@@ -182,7 +182,6 @@ test('falls back to global fetch when undici cannot be loaded', async () => {const fallbackFetch = vi.fn(() =>Promise.resolve(new Response('fallback ok'))) as unknown as typeof fetch- const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})vi.stubGlobal('fetch', fallbackFetch)const { createEnvdFetchForRuntime } = await import('../../src/envd/http2')@@ -197,7 +196,6 @@ test('falls back to global fetch when undici cannot be loaded', async () => {'https://example.com/status',undefined)- expect(warn).toHaveBeenCalledOnce()})test('uses global fetch outside Node', async () => {