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 signal, 135 } satisfies http.RequestOptions; 136 137 - requestOptions.agent = 138 - requestOptions.protocol === 'https:' 139 - ? getHttpsAgent(requestOptions) 140 - : getHttpAgent(requestOptions); 141 - 142 function _call( 143 resolve: (response: Response | Promise<Response>) => void, 144 reject: (reason?: any) => void 145 ) { 146 const method = requestOptions.method; 147 const protocol = requestOptions.protocol === 'https:' ? https : http; 148 const outgoing = protocol.request(requestOptions);
··· 134 signal, 135 } satisfies http.RequestOptions; 136 137 function _call( 138 resolve: (response: Response | Promise<Response>) => void, 139 reject: (reason?: any) => void 140 ) { 141 + requestOptions.agent = 142 + requestOptions.protocol === 'https:' 143 + ? getHttpsAgent(requestOptions) 144 + : getHttpAgent(requestOptions); 145 const method = requestOptions.method; 146 const protocol = requestOptions.protocol === 'https:' ? https : http; 147 const outgoing = protocol.request(requestOptions);