evilmartians / lefthook

Fast and powerful Git hooks manager for any type of projects.
MIT License
4.99k stars 218 forks source link

pre push long running tests ends up with remote push errors #255

Open MassivDash opened 2 years ago

MassivDash commented 2 years ago

Hello

For pre push hook, I have a build and run tests steps. Everything seemed fine at first but as the tests grew in numbers, I got the following error

SUMMARY: (done in 359.17 seconds)
✔️  tests
✔️  build
Enumerating objects: 99, done.
Counting objects: 100% (72/72), done.
Delta compression using up to 12 threads
Compressing objects: 100% (36/36), done.
Writing objects: 100% (36/36), 280.76 KiB | 3.95 MiB/s, done.
Total 36 (delta 24), reused 0 (delta 0), pack-reused 0
client_loop: send disconnect: Broken pipe
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly

git push --no-verify works as expected, and changes get pushed.

I tried using the parallel flag, but this way the actual push cmd does not get triggered at the end at all.

Node 16, Windows and Mac systems

MassivDash commented 2 years ago

This is still an issue with 1.05 version

SUMMARY: (done in 354.58 seconds)
✔️  build
✔️  tests
✨  Done in 354.95s.
Enumerating objects: 19, done.
Counting objects: 100% (19/19), done.
Delta compression using up to 6 threads
client_loop: send disconnect: Broken pipe
send-pack: unexpected disconnect while reading sideband packet
Compressing objects: 100% (10/10), done.
fatal: the remote end hung up unexpectedly

I tried to resolve this issue with these stackoverflow answers but with no luck, https://stackoverflow.com/questions/66366582/github-unexpected-disconnect-while-reading-sideband-packet

mrexox commented 2 years ago

Hey! Could you share your code and/or lefthook.yml file?

MassivDash commented 2 years ago
pre-push:
  parallel: false
  commands:
    build:
      tags: Projects builds
      run: npm run build
    tests:
      tags: Run project tests and eslint for whole project
      run: npm run ci:jest

pre-commit:
  parallel: true
  commands:
    linter:
      files: git diff --name-only HEAD @{push}
      glob: '*.{js,ts,jsx,tsx}'
      run: npx eslint {staged_files} --fix
    tests:
      files: git diff --name-only HEAD @{push}
      glob: '*.{js,ts, jsx, tsx}'
      run: jest --findRelatedTests {staged_files} --passWithNoTests

commit-msg:
  commands:
    validate:
      run: npx commitlint  --edit
mrexox commented 2 years ago

Hey! It seems to be working well for me but I don't know what are the files you build and test. Let's find the issue:

  1. Does it work if you run lefthook uninstall --keep-config. This will delete the hooks but keep the config file. Would it push successfully then?
  2. If 1st point works, does it work with LEFTHOOK=0 git push?
  3. If 2nd point works, does it always break on git push or just sometimes?

It seems like lefthook works as it is expected, but something breaks while pushing the changes. Maybe a network issue. Anyway, I will appreciate if you check the steps.

MassivDash commented 2 years ago
  1. Push works
  2. Push works
  3. It always breaks for me.

I have updated to 1.1.0 but its still the same issue, this time actually i got stuck a little longer on this step

UMMARY: (done in 375.82 seconds)
✔️  build
✔️  tests
✨  Done in 376.20s.
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 6 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.12 KiB | 1.12 MiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0

but after few seconds i got the usual

client_loop: send disconnect: Broken pipe
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly

push no verify works as expected. Is there like a debug mode I can enable ? Like i mentioned before this started to happen after the tests grew enough for the step to run for 6+ minutes, before it worked fine, maybe there is a timeout or something like that. I'll try to reduce the tests and find out the breaking point, removing the tests makes it work as expected

SUMMARY: (done in 69.09 seconds)
✔️  build
✨  Done in 69.46s.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 6 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 320 bytes | 320.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Analyzing objects... (3/3) (402 ms)
remote: Storing packfile... done (117 ms)
remote: Storing index... done (128 ms)