The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Report body-read failures as network errors in the HTTP client
Rafib91460215a04
diff --git a/apps/web/lib/dynadot/search-domains.ts b/apps/web/lib/dynadot/search-domains.tsindex 49e37ede10..d378d52bef 100644--- a/apps/web/lib/dynadot/search-domains.ts+++ b/apps/web/lib/dynadot/search-domains.ts@@ -67,13 +67,10 @@ async function searchWithRetry(timeout: SEARCH_TIMEOUT_MS,});} catch (error) {- // A null status means Dynadot sent no response (network error or timeout).+ // A null status means Dynadot sent no full response (network error or timeout, also during the body read).// Request validation errors also have a null status, but the route validates the domain first.- // The timeout can also abort the body read after the headers arrived, which throws a plain TimeoutError.const noResponse =- (error instanceof HttpClientError && error.status === null) ||- (error instanceof Error &&- (error.name === "TimeoutError" || error.name === "AbortError"));+ error instanceof HttpClientError && error.status === null;if (!noResponse) {throw error;diff --git a/apps/web/lib/http/base-client.ts b/apps/web/lib/http/base-client.tsindex 78d90916f3..1ae1b2a02e 100644--- a/apps/web/lib/http/base-client.ts+++ b/apps/web/lib/http/base-client.ts@@ -252,7 +252,35 @@ export abstract class HttpBaseClient {});}- const text = await response.text();+ // The body read can still fail after the headers arrived (a timeout or a dropped connection).+ // Report it like a network error, so callers can retry it the same way.+ let text: string;++ try {+ text = await response.text();+ } catch (error) {+ const reason = error instanceof Error ? error.message : String(error);+ const message = `[${this.vendor}] ${method} ${safeUrl} network error while reading the response: ${reason}`;++ waitUntil(+ this.logError(message, {+ method,+ url: safeUrl,+ status: response.status,+ error: reason,+ }),+ );++ throw new HttpClientError({+ vendor: this.vendor,+ method,+ url: safeUrl,+ status: null,+ responseBody: null,+ message,+ });+ }+let data: unknown = null;if (text) {