refactor: clean-up error handling on task execution #1400

Merged
mfenniak merged 3 commits from mfenniak/forgejo-runner:refactor-task-errors into main 2026-02-23 15:21:56 +00:00
Owner

The goal I had in mind was to make sure that once the runner has a task from FetchTask, it never has any error cases that don't get reported back to the server. I believe that's already practically the case, but I've applied a couple refactorings to clarify it:

  • Run() no longer returns an error, to indicate that its expected to handle errors internally. Nearly no code paths used this.
  • runningTasks (the only code path using the above) had a possibility for a race condition which could allow two instances of the same task to be run, which was fixed up.
  • recover() is used when running jobs in a way that would not report status back to the server. But practically speaking these recover() blocks were never used because panics from within the job invocation are also recovered.

So, I think this just ends up as a refactor that removes some unused error handling, but it helps clarify that no error cases seem to exist that won't report status.

  • other
    • PR: refactor: clean-up error handling on task execution
The goal I had in mind was to make sure that once the runner has a task from `FetchTask`, it never has any error cases that don't get reported back to the server. I believe that's already practically the case, but I've applied a couple refactorings to clarify it: - `Run()` no longer returns an error, to indicate that its expected to handle errors internally. Nearly no code paths used this. - `runningTasks` (the only code path using the above) had a possibility for a race condition which could allow two instances of the same task to be run, which was fixed up. - `recover()` is used when running jobs in a way that would not report status back to the server. But practically speaking these `recover()` blocks were never used because panics from within the job invocation [are also recovered](https://code.forgejo.org/forgejo/runner/src/commit/142689a39abeb50df8ea9f1b543ab8622b43a3b9/internal/app/run/runner.go#L231-L235). So, I think this just ends up as a refactor that removes some unused error handling, but it helps clarify that no error cases seem to exist that won't report status. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/1400): <!--number 1400 --><!--line 0 --><!--description cmVmYWN0b3I6IGNsZWFuLXVwIGVycm9yIGhhbmRsaW5nIG9uIHRhc2sgZXhlY3V0aW9u-->refactor: clean-up error handling on task execution<!--description--> <!--end release-notes-assistant-->
refactor: remove unnecessary recover() clauses
Some checks failed
checks / Build Forgejo Runner (pull_request) Successful in 54s
checks / validate mocks (pull_request) Successful in 51s
issue-labels / release-notes (pull_request_target) Successful in 6s
checks / validate pre-commit-hooks file (pull_request) Successful in 40s
checks / Build unsupported platforms (pull_request) Successful in 30s
checks / runner exec tests (pull_request) Successful in 36s
checks / Run integration tests with Docker (docker-latest) (pull_request) Failing after 10m5s
checks / Run integration tests with Docker (docker-stable) (pull_request) Failing after 12m13s
checks / Run integration tests with Podman (pull_request) Has been cancelled
883d47c9e6
mfenniak force-pushed refactor-task-errors from 883d47c9e6
Some checks failed
checks / Build Forgejo Runner (pull_request) Successful in 54s
checks / validate mocks (pull_request) Successful in 51s
issue-labels / release-notes (pull_request_target) Successful in 6s
checks / validate pre-commit-hooks file (pull_request) Successful in 40s
checks / Build unsupported platforms (pull_request) Successful in 30s
checks / runner exec tests (pull_request) Successful in 36s
checks / Run integration tests with Docker (docker-latest) (pull_request) Failing after 10m5s
checks / Run integration tests with Docker (docker-stable) (pull_request) Failing after 12m13s
checks / Run integration tests with Podman (pull_request) Has been cancelled
to 071fe7c233
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 5s
checks / validate pre-commit-hooks file (pull_request) Successful in 37s
checks / Build Forgejo Runner (pull_request) Successful in 45s
checks / validate mocks (pull_request) Successful in 46s
checks / Build unsupported platforms (pull_request) Successful in 18s
checks / runner exec tests (pull_request) Successful in 26s
checks / Run integration tests with Docker (docker-latest) (pull_request) Failing after 9m5s
checks / Run integration tests with Docker (docker-stable) (pull_request) Failing after 11m18s
checks / Run integration tests with Podman (pull_request) Failing after 15m14s
2026-02-23 01:17:14 +00:00
Compare
mfenniak force-pushed refactor-task-errors from 071fe7c233
Some checks failed
cascade / forgejo (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Has been skipped
cascade / debug (pull_request_target) Has been skipped
issue-labels / release-notes (pull_request_target) Successful in 5s
checks / validate pre-commit-hooks file (pull_request) Successful in 37s
checks / Build Forgejo Runner (pull_request) Successful in 45s
checks / validate mocks (pull_request) Successful in 46s
checks / Build unsupported platforms (pull_request) Successful in 18s
checks / runner exec tests (pull_request) Successful in 26s
checks / Run integration tests with Docker (docker-latest) (pull_request) Failing after 9m5s
checks / Run integration tests with Docker (docker-stable) (pull_request) Failing after 11m18s
checks / Run integration tests with Podman (pull_request) Failing after 15m14s
to 3a5575be1f
All checks were successful
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / validate pre-commit-hooks file (pull_request) Successful in 36s
checks / validate mocks (pull_request) Successful in 42s
checks / Build Forgejo Runner (pull_request) Successful in 43s
checks / Build unsupported platforms (pull_request) Successful in 20s
checks / runner exec tests (pull_request) Successful in 26s
checks / Run integration tests with Docker (docker-latest) (pull_request) Successful in 9m4s
checks / Run integration tests with Docker (docker-stable) (pull_request) Successful in 11m14s
checks / Run integration tests with Podman (pull_request) Successful in 15m5s
cascade / debug (pull_request_target) Has been skipped
cascade / end-to-end (pull_request_target) Successful in 5s
cascade / forgejo (pull_request_target) Successful in 1m22s
2026-02-23 01:44:42 +00:00
Compare
aahlenst approved these changes 2026-02-23 14:01:01 +00:00
aahlenst left a comment
Member

Very nice simplification.

Very nice simplification.
mfenniak deleted branch refactor-task-errors 2026-02-23 15:21:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/runner!1400
No description provided.