Skip to content

Commit

Permalink
Merge pull request #114 from golemfactory/build/bump-golem-js-to-3.3.0
Browse files Browse the repository at this point in the history
fix(deps): bumping up golem-js to 3.3 to get new improvements and fixes
  • Loading branch information
grisha87 authored Sep 4, 2024
2 parents 84cd20a + b487ce9 commit 022b22e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"node": ">=18"
},
"dependencies": {
"@golem-sdk/golem-js": "^3.2.0",
"@golem-sdk/golem-js": "^3.3.0",
"@golem-sdk/pino-logger": "^1.1.0",
"@golem-sdk/task-executor": "file:..",
"commander": "^12.0.0",
Expand Down
23 changes: 11 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@golem-sdk/golem-js": "^3.2.0",
"@golem-sdk/golem-js": "^3.3.0",
"eventemitter3": "^5.0.1"
},
"devDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export class TaskService {
}

private async startTask(task: Task) {
const abortController = new AbortController();
const { signal, cleanup } = anyAbortSignal(this.abortController.signal, abortController.signal);
try {
task.init();
this.logger.debug(`Starting task`, { taskId: task.id, attempt: task.getRetriesCount() + 1 });
Expand All @@ -85,13 +87,11 @@ export class TaskService {
throw new GolemInternalError(`Execution of task ${task.id} aborted due to error. ${task.getError()}`);
}

const abortController = new AbortController();
task.onStateChange((state) => {
if (state === TaskState.Rejected || state === TaskState.Retry) {
abortController.abort();
}
});
const signal = anyAbortSignal(this.abortController.signal, abortController.signal);
const rental = await this.resourceRentalPool.acquire(signal);

if (task.isFailed()) {
Expand All @@ -116,6 +116,8 @@ export class TaskService {
error,
error instanceof GolemWorkError || (error instanceof GolemTimeoutError && task.retryOnTimeout),
);
} finally {
cleanup();
}
}

Expand Down

0 comments on commit 022b22e

Please sign in to comment.