Skip to content

Commit

Permalink
include request payload in timeout error
Browse files Browse the repository at this point in the history
  • Loading branch information
rnons committed Jul 21, 2024
1 parent a8bb663 commit f7deb70
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src.ts/utils/geturl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ export function createGetUrl(options?: Record<string, any>): FetchGetUrlFunc {
}

request.on("timeout", () => {
reject(makeError("request timeout", "TIMEOUT"));
let payload
if (body) {
try {
payload = JSON.parse(Buffer.from(body).toString('utf8'))
} catch (e) {}
}
reject(makeError("request timeout", "TIMEOUT", { payload }));
});

request.once("response", (resp: http.IncomingMessage) => {
Expand Down Expand Up @@ -131,4 +137,3 @@ const defaultGetUrl: FetchGetUrlFunc = createGetUrl({ });
export async function getUrl(req: FetchRequest, signal?: FetchCancelSignal): Promise<GetUrlResponse> {
return defaultGetUrl(req, signal);
}

0 comments on commit f7deb70

Please sign in to comment.