Failed / exit code: -9 when using pre-commit >=3.4.0 and a lot of files
After updating pre-commit to a version >=3.4.0 the typos hook starts to fail for us. Issue seems to behave different on amd64 vs aarch64, but can be reproduced stable with these simple script that just creates 30.000 files, each within its own folder:
test.sh
!#/bin/bash
cd tmp
for i in {1..30000}; do tdir="$(mktemp -d ./foo.XXXXXXXXX)" ;tfile="$(mktemp $tdir/foo.XXXXXXXXX.json)"; echo foo > $tfile; echo $i ; done
cat << EOF > .pre-commit-config.yaml
repos:
- repo: https://github.com/crate-ci/typos
rev: v1.18.0
hooks:
# Hook does not autofix on purpose. Better safe than sorry.
- id: typos
args: [--no-check-filenames]
EOF
git init
git add -A
echo '################################ run with pre-commit==3.6.0'
pip install -q pre-commit==3.6.0
pre-commit run --all-files typos
echo '################################ run with pre-commit==3.3.3'
pip install -q pre-commit==3.3.3
pre-commit run --all-files typos
I just ran it in a docker container to keep stuff clean:
docker run --rm -ti -v $PWD/test.sh:/tmp/test.sh --entrypoint=/bin/bash python:3.11.7
(compressed) result:
################################ run with pre-commit==3.6.0
typos....................................................................Failed
- hook id: typos
- exit code: -9
-
################################ run with pre-commit==3.3.3
typos....................................................................Passed
There was some change towards negative signals introduced with 3.4.0, see https://github.com/pre-commit/pre-commit/issues/2970.
I guess, typos ran by pre-commit can't handle a lot of files and "dies", which it may have done before, but without any visible signs.
Running typos directly,. I am not able to reproduce this.
Running
typosdirectly,. I am not able to reproduce this.
Can confirm that. Happens only when using pre-commit