gitforge/modules
forgejo-backport-action efcc25c5a6 [v15.0/forgejo] fix: intermittent test failure in process cancellation (#13301)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/13293

Test failure: https://codeberg.org/forgejo/forgejo/actions/runs/174007/jobs/2/attempt/1   Have only observed once and can't reproduce locally, but likely caused by #13263 / #13289.

```
--- FAIL: TestGetDiffPreview (0.20s)
    --- FAIL: TestGetDiffPreview/empty_branch,_same_results (0.02s)
        diff_test.go:132:
            	Error Trace:	/workspace/forgejo/forgejo/services/repository/files/diff_test.go:132
            	Error:      	Received unexpected error:
            	            	unable to run diff-index pipeline in temporary repo: exec: canceling Cmd: invalid argument
            	Test:       	TestGetDiffPreview/empty_branch,_same_results
FAIL
```

pidfd_open is [documented](https://www.man7.org/linux/man-pages/man2/pidfd_open.2.html) to return the EINVAL (invalid argument) error if the pid is not valid, which could happen if the process terminates itself before Forgejo sends `SIGTERM`.  This PR adds a check for that error and stops `Cancel`, with a minor refactor to avoid code duplication.

### Tests for Go changes

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I ran...
  - [x] `make pr-go` before pushing

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [ ] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [x] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/13301
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
2026-07-04 05:48:16 +02:00
..
actions [v15.0/forgejo] fix: do not try to remove task logs that don't exist (#13055) 2026-06-21 14:55:36 +02:00
activitypub feat: backend DB model for fine-grained repo access tokens 2026-02-27 17:17:29 +01:00
analyze
assetfs feat: optimization: use fs.ReadFile (#10987) 2026-01-22 16:26:18 +01:00
auth [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
avatar [v15.0/forgejo] chore: remove EXIF stripping capability due to usage of AGPL licensed exif-terminator library (#13115) 2026-06-17 17:11:36 +02:00
base feat(ui): dedicated icon for CITATION file (#10873) 2026-01-17 10:10:56 +01:00
cache chore: fix typos throughout the codebase (#10753) 2026-01-26 22:57:33 +01:00
card
charset [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
container
csv
emoji
eventsource ci: detect and prevent empty case statements in Go code (#11593) 2026-03-10 02:50:28 +01:00
forgefed [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
generate
git [v15.0/forgejo] fix: terminate git (& other) subcommands gracefully on context timeout/cancellation (#13273) 2026-07-01 21:56:17 +02:00
gitrepo
graceful ci: detect and prevent empty case statements in Go code (#11593) 2026-03-10 02:50:28 +01:00
hcaptcha
highlight
hostmatcher [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
html
httpcache [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
httplib [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
indexer [v15.0/forgejo] fix: load repo language for converting to api struct (#12789) 2026-05-28 18:02:09 +02:00
issue/template [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
json
jwtx chore: Add JWT() method for convenience and clarity (#11067) 2026-02-07 01:01:30 +01:00
keying [v15.0/forgejo] fix: store pull mirror creds encrypted with keying (#11984) 2026-04-04 14:47:05 +02:00
label [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
lfs
log [v15.0/forgejo] fix: terminate git (& other) subcommands gracefully on context timeout/cancellation (#13273) 2026-07-01 21:56:17 +02:00
markup [v15.0/forgejo] fix: terminate git (& other) subcommands gracefully on context timeout/cancellation (#13273) 2026-07-01 21:56:17 +02:00
mcaptcha
metrics
migration ci: detect and prevent empty case statements in Go code (#11593) 2026-03-10 02:50:28 +01:00
nosql
optional chore: support Option[T] as a type on database schema structs (#11553) 2026-03-08 03:36:32 +01:00
options
packages [v15.0/forgejo] fix: Update swift package registry to use the metadata schema from the official Swift docs (#13209) 2026-06-27 23:53:56 +02:00
paginator
pprof
private [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
process [v15.0/forgejo] fix: intermittent test failure in process cancellation (#13301) 2026-07-04 05:48:16 +02:00
proxy
proxyprotocol ci: detect and prevent empty case statements in Go code (#11593) 2026-03-10 02:50:28 +01:00
public [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
queue [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
recaptcha
references
regexplru
repository [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
secret
session fix: only destroy session if exists 2026-03-19 02:18:52 +01:00
setting [v15.0/forgejo] fix: terminate git (& other) subcommands gracefully on context timeout/cancellation (#13273) 2026-07-01 21:56:17 +02:00
sitemap
ssh [v15.0/forgejo] fix: terminate git (& other) subcommands gracefully on context timeout/cancellation (#13273) 2026-07-01 21:56:17 +02:00
storage chore: use require.Error() over require.Errorf() (#11037) 2026-01-25 19:36:02 +01:00
structs [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
svg
sync
system
templates [v15.0/forgejo] fix: store pull mirror creds encrypted with keying (#11984) 2026-04-04 14:47:05 +02:00
test [v15.0/forgejo] fix: ensure migrations allow/deny host lists are applied to onedev, pagure, and codebase migrators (#13220) 2026-06-27 22:51:05 +02:00
testimport
testlogger [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
timeutil
translation [v15.0/forgejo] fix(i18n): don't log harmless missing translations as errors (#12185) 2026-04-19 01:46:40 +02:00
turnstile
typesniffer
updatechecker [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
uri
user
util [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
validation [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
web chore(refactor): run routers/api/v1/permissions/tests from tests/integration (#13157) 2026-06-21 22:49:02 +02:00
webhook
zstd