From a43a46da7d738bb5abc8422a5bdac0e0b3234932 Mon Sep 17 00:00:00 2001 From: himanshu Date: Thu, 9 May 2024 21:28:49 +0530 Subject: [PATCH 1/2] log failed requests with final error msg --- src/helpers/nodeUtils.ts | 6 ++---- src/some.ts | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/helpers/nodeUtils.ts b/src/helpers/nodeUtils.ts index 2df03f8..735fa1c 100644 --- a/src/helpers/nodeUtils.ts +++ b/src/helpers/nodeUtils.ts @@ -208,9 +208,7 @@ export async function retrieveOrImportShare(params: { }), null, { logTracingHeader: config.logRequestTracing } - ).catch((err) => { - log.error("commitment error", err); - }); + ); promiseArr.push(p); } // send share request once k + t number of commitment requests have completed @@ -294,7 +292,7 @@ export async function retrieveOrImportShare(params: { }), null, { logTracingHeader: config.logRequestTracing } - ).catch((err) => log.error("share req", err)); + ); promiseArrRequest.push(p); } else { const p = post>( diff --git a/src/some.ts b/src/some.ts index b16e8b2..ca72333 100644 --- a/src/some.ts +++ b/src/some.ts @@ -10,9 +10,13 @@ export class SomeError extends Error { predicate: string; constructor({ errors, responses, predicate }: { errors: Error[]; responses: T[]; predicate: string }) { + // its fine to log responses in errors logs for better debugging, + // as data is always encrypted with temp key + // temp key should not be logged anywhere const message = `Unable to resolve enough promises. errors: ${errors.map((x) => x?.message || x).join(", ")}, ${responses.length} responses, + responses: ${JSON.stringify(responses)}, predicate error: ${predicate}`; super(message); this.errors = errors; From 18925527ceb7e234f5863631fb3922918d98c052 Mon Sep 17 00:00:00 2001 From: himanshu Date: Fri, 10 May 2024 11:15:00 +0530 Subject: [PATCH 2/2] remove catch from get share request and remove dep on node index 1 --- src/helpers/nodeUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/nodeUtils.ts b/src/helpers/nodeUtils.ts index 735fa1c..9f6e607 100644 --- a/src/helpers/nodeUtils.ts +++ b/src/helpers/nodeUtils.ts @@ -228,7 +228,7 @@ export async function retrieveOrImportShare(params: { return Promise.resolve(resultArr); } else if (importedShares?.length === 0 && completedRequests.length >= ~~((endpoints.length * 3) / 4) + 1) { const requiredNodeResult = completedRequests.find((resp: void | JRPCResponse) => { - if (resp && resp.result?.nodeindex === "1") { + if (resp) { return true; } return false; @@ -315,7 +315,7 @@ export async function retrieveOrImportShare(params: { }), null, { logTracingHeader: config.logRequestTracing } - ).catch((err) => log.error("share req", err)); + ); promiseArrRequest.push(p); } }