Skip to content

Commit

Permalink
fix: corrects sync vs async log
Browse files Browse the repository at this point in the history
  • Loading branch information
krpeacock committed Aug 13, 2024
1 parent dd3e4c9 commit 445b6a9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/agent/src/agent/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,24 +469,30 @@ export class HttpAgent implements Agent {
const backoff = this.#backoffStrategy();
try {
// Attempt v3 sync call
const requestSync = () =>
this.#fetch('' + new URL(`/api/v3/canister/${ecid.toText()}/call`, this.host), {
const requestSync = () => {
this.log.print(
`fetching "/api/v3/canister/${ecid.toText()}/call" with request:`,
transformedRequest,
);
return this.#fetch('' + new URL(`/api/v3/canister/${ecid.toText()}/call`, this.host), {
...this.#callOptions,
...transformedRequest.request,
body,
});
};

const requestAsync = () =>
this.#fetch('' + new URL(`/api/v2/canister/${ecid.toText()}/call`, this.host), {
const requestAsync = () => {
this.log.print(
`fetching "/api/v2/canister/${ecid.toText()}/call" with request:`,
transformedRequest,
);
return this.#fetch('' + new URL(`/api/v2/canister/${ecid.toText()}/call`, this.host), {
...this.#callOptions,
...transformedRequest.request,
body,
});
};

this.log.print(
`fetching "/api/v3/canister/${ecid.toText()}/call" with request:`,
transformedRequest,
);

const request = this.#requestAndRetry({
request: callSync ? requestSync : requestAsync,
Expand Down

0 comments on commit 445b6a9

Please sign in to comment.