From d29a60a6ce8da92d8b1cb70eb8202bd757b0aaf5 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Wed, 28 Jun 2023 17:26:11 -0400 Subject: [PATCH 1/2] fix: disallow using the global fetch with `agent` option --- src/fetch-wrapper.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/fetch-wrapper.ts b/src/fetch-wrapper.ts index 2158fdc3a..fa67c6d09 100644 --- a/src/fetch-wrapper.ts +++ b/src/fetch-wrapper.ts @@ -36,6 +36,17 @@ export default function fetchWrapper( ); } + if ( + typeof globalThis.fetch !== "undefined" && + typeof requestOptions.request?.agent !== "undefined" + ) { + throw new Error( + `Global "fetch" and "agent" options cannot be used together, + please use a custom fetch function with the "dispatcher" option, + or use "node-fetch" instead. See https://github.com/octokit/octokit.js/discussions/2484` + ); + } + return fetch( requestOptions.url, Object.assign( From fd4a20a9d2c4bd27ca5eb499fc3ad4fec7a43e06 Mon Sep 17 00:00:00 2001 From: wolfy1339 Date: Wed, 28 Jun 2023 17:28:06 -0400 Subject: [PATCH 2/2] docs(README): note that the agent option is only for node-fetch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d96549dcd..45c4b7ce7 100644 --- a/README.md +++ b/README.md @@ -302,7 +302,7 @@ const { data: app } = await requestWithAuth( - options.request.agent + options.request.agent (node-fetch only) http(s).Agent instance