From 445b6a975b87957bc101789e4aa9c95ff0b17413 Mon Sep 17 00:00:00 2001 From: Kyle Peacock Date: Tue, 13 Aug 2024 13:36:39 -0700 Subject: [PATCH] fix: corrects sync vs async log --- packages/agent/src/agent/http/index.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/agent/src/agent/http/index.ts b/packages/agent/src/agent/http/index.ts index 0cf816f3..53928a0e 100644 --- a/packages/agent/src/agent/http/index.ts +++ b/packages/agent/src/agent/http/index.ts @@ -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,