Skip to content

Commit f6fedee

Browse files
authored
Fix passing body in retry logic (#1321)
The compressed body wasn't passed along.
1 parent a83d3f2 commit f6fedee

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

.generator/src/generator/templates/http/isomorphic-fetch.j2

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
5151
}
5252
}
5353

54-
return this.executeRequest(request,0,headers);
54+
return this.executeRequest(request, body, 0, headers);
5555
}
5656

5757
private async executeRequest(
5858
request: RequestContext,
59+
body: any,
5960
currentAttempt: number,
6061
headers: {[key: string]: string}
6162
): Promise<ResponseContext> {
@@ -66,7 +67,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
6667
const fetchFunction =!isNode && typeof fetch === "function" ? fetch : crossFetch;
6768
const fetchOptions = {
6869
method: request.getHttpMethod().toString(),
69-
body: request.getBody() as any,
70+
body: body,
7071
headers: headers,
7172
signal: request.getHttpConfig().signal,
7273
}
@@ -108,12 +109,12 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
108109
this.backoffBase,
109110
this.backoffMultiplier,
110111
responseHeaders
111-
);
112-
currentAttempt++;
113-
await this.sleep(delay * 1000);
114-
return this.executeRequest(request, currentAttempt, headers);
115-
}
116-
return response;
112+
);
113+
currentAttempt++;
114+
await this.sleep(delay * 1000);
115+
return this.executeRequest(request, body, currentAttempt, headers);
116+
}
117+
return response;
117118
} catch (error) {
118119
console.error("An error occurred during the HTTP request:", error);
119120
throw error;

packages/datadog-api-client-common/http/isomorphic-fetch.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
5656
}
5757
}
5858

59-
return this.executeRequest(request, 0, headers);
59+
return this.executeRequest(request, body, 0, headers);
6060
}
6161

6262
private async executeRequest(
6363
request: RequestContext,
64+
body: any,
6465
currentAttempt: number,
6566
headers: { [key: string]: string }
6667
): Promise<ResponseContext> {
@@ -72,7 +73,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
7273
!isNode && typeof fetch === "function" ? fetch : crossFetch;
7374
const fetchOptions = {
7475
method: request.getHttpMethod().toString(),
75-
body: request.getBody() as any,
76+
body: body,
7677
headers: headers,
7778
signal: request.getHttpConfig().signal,
7879
};
@@ -117,7 +118,7 @@ export class IsomorphicFetchHttpLibrary implements HttpLibrary {
117118
);
118119
currentAttempt++;
119120
await this.sleep(delay * 1000);
120-
return this.executeRequest(request, currentAttempt, headers);
121+
return this.executeRequest(request, body, currentAttempt, headers);
121122
}
122123
return response;
123124
} catch (error) {

0 commit comments

Comments
 (0)