From 3b41bf98e64bc6e1d436afa8e174661e41d0a6d0 Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Mon, 10 Jun 2024 12:56:32 +0200 Subject: [PATCH] refactor(eas-cli): use built-in Node fetch instead of undici --- packages/eas-cli/__mocks__/undici.ts | 7 ------- packages/eas-cli/src/fetch.ts | 16 ++++++---------- 2 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 packages/eas-cli/__mocks__/undici.ts diff --git a/packages/eas-cli/__mocks__/undici.ts b/packages/eas-cli/__mocks__/undici.ts deleted file mode 100644 index 845866e561..0000000000 --- a/packages/eas-cli/__mocks__/undici.ts +++ /dev/null @@ -1,7 +0,0 @@ -const undici = require('undici'); - -// This workaround swaps `undici.fetch` for `global.fetch` to connect Nock with Undici. -// See: https://github.com/nock/nock/issues/2183 -require('nock'); - -module.exports = { ...undici, fetch: global.fetch }; diff --git a/packages/eas-cli/src/fetch.ts b/packages/eas-cli/src/fetch.ts index 648029f4e7..6dc475c9c9 100644 --- a/packages/eas-cli/src/fetch.ts +++ b/packages/eas-cli/src/fetch.ts @@ -1,15 +1,11 @@ import { env } from 'node:process'; -import { - ProxyAgent, - type RequestInfo, - type RequestInit, - type Response, - fetch, - getGlobalDispatcher, - setGlobalDispatcher, -} from 'undici'; +import { ProxyAgent, getGlobalDispatcher, setGlobalDispatcher } from 'undici'; -export { Agent, Headers, type RequestInfo, type RequestInit, Response } from 'undici'; +// Re-export the fetch-related Node globals +export type RequestInfo = globalThis.RequestInfo; +export type RequestInit = globalThis.RequestInit; +export type Response = globalThis.Response; +export const Headers = globalThis.Headers; export class RequestError extends Error { constructor(