Skip to content

Commit

Permalink
chore: improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pociej committed Jun 18, 2024
1 parent 1da4193 commit 275b5db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/src/services/yagna/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,21 @@ export class Yagna {
let executor, worker, agreement;
try {
executor = await this.userContext.getExecutor(userId);
debugLog("yagna", "making agreement, executor found", userId);

//in order to make sure agreement wont be automatically closed after 90s
//which is HARDCODED in yagna we make worker which under the hood makes activity
// which prevents agreement from closing
worker = await this.getUserWorker(userId);

debugLog("yagna", "making agreement, worker found", userId);
agreement = await worker.context?.activity.agreement;
debugLog("yagna", "making agreement, agreement found", agreement);
} catch (e) {
console.log("Error", e);
}

if (!agreement) {
debugLog("yagna", "Error making agreement, no agreement found", userId);
throw new Error({
code: ErrorCode.UNABLE_TO_CREATE_AGREEMENT,
});
Expand Down Expand Up @@ -288,7 +292,7 @@ export class Yagna {
return new Promise(async (resolve, reject) => {
const worker = this.userContext.getWorker(userId);
if (worker) {
debugLog("yagna", "worker found", userId);
debugLog("yagna", "getUSerWorker: worker found", userId);
const isConnected = await worker.isConnected();
if (isConnected) {
debugLog("yagna", "worker connected", userId);
Expand Down

0 comments on commit 275b5db

Please sign in to comment.