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

Configure Feed

Select the types of activity you want to include in your feed.

fix: Add explicit `ETIMEDOUT` when connection doesn't establish with headers (#24)

authored by

Phil Pluckthun and committed by
GitHub
b2085f98 93d78107

+13
+5
.changeset/gold-impalas-think.md
··· 1 + --- 2 + 'fetch-nodeshim': patch 3 + --- 4 + 5 + Issue an explicit `ETIMEDOUT` when the request times out
+8
src/fetch.ts
··· 160 160 161 161 signal?.addEventListener('abort', destroy); 162 162 163 + outgoing.on('timeout', () => { 164 + if (!incoming) { 165 + const error = new Error('Request timed out') as NodeJS.ErrnoException; 166 + error.code = 'ETIMEDOUT'; 167 + destroy(error); 168 + } 169 + }); 170 + 163 171 outgoing.on('response', _incoming => { 164 172 if (signal?.aborted) { 165 173 return;