Mirror: A Node.js fetch shim using built-in Request, Response, and Headers (but without native fetch)

fix: Reset `agent` on retry/redirect (#27)

authored by kitten.sh and committed by GitHub 7e469cc2 8ee7ffee

+9 -5
+5
.changeset/slimy-boats-worry.md
··· 1 + --- 2 + 'fetch-nodeshim': patch 3 + --- 4 + 5 + Reset `requestOptions.agent` on retry/redirect
+4 -5
src/fetch.ts
··· 134 134 signal, 135 135 } satisfies http.RequestOptions; 136 136 137 - requestOptions.agent = 138 - requestOptions.protocol === 'https:' 139 - ? getHttpsAgent(requestOptions) 140 - : getHttpAgent(requestOptions); 141 - 142 137 function _call( 143 138 resolve: (response: Response | Promise<Response>) => void, 144 139 reject: (reason?: any) => void 145 140 ) { 141 + requestOptions.agent = 142 + requestOptions.protocol === 'https:' 143 + ? getHttpsAgent(requestOptions) 144 + : getHttpAgent(requestOptions); 146 145 const method = requestOptions.method; 147 146 const protocol = requestOptions.protocol === 'https:' ? https : http; 148 147 const outgoing = protocol.request(requestOptions);