Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push doesn't always occur #705

Closed
bduff9 opened this issue Apr 9, 2020 · 17 comments
Closed

Push doesn't always occur #705

bduff9 opened this issue Apr 9, 2020 · 17 comments
Labels

Comments

@bduff9
Copy link

bduff9 commented Apr 9, 2020

Before creating an issue, see troubleshoot section in the README and verify that you're using Git >= 2.13.0.

Please provide your OS, terminal and the following commands output:
OS: Mac 10.15.4
Terminal: ZSH/VS Code Git Client
Git: 2.18.0

$ HUSKY_DEBUG=1 npm install husky --save-dev
> [email protected] preuninstall /Users/brianduffey/project/node_modules/husky
> node husky uninstall

husky:debug Current working directory is '/Users/brianduffey/project/node_modules/husky'
husky:debug INIT_CWD environment variable is set to '/Users/brianduffey/project'
husky > Uninstalling git hooks
husky:debug Git rev-parse command returned:
husky:debug   --show-top-level: /Users/brianduffey/project
husky:debug   --git-common-dir: ../../.git
husky > Done

> [email protected] install /Users/brianduffey/project/node_modules/husky
> node husky install

husky:debug Current working directory is '/Users/brianduffey/project/node_modules/husky'
husky:debug INIT_CWD environment variable is set to '/Users/brianduffey/project'
husky > Setting up git hooks
husky:debug Git rev-parse command returned:
husky:debug   --show-top-level: /Users/brianduffey/project
husky:debug   --git-common-dir: ../../.git
husky:debug Installing hooks in '../../.git/hooks'
husky > Done

> [email protected] postinstall /Users/brianduffey/project/node_modules/husky
> opencollective-postinstall || exit 0

Thank you for using husky!
If you rely on this package, please consider supporting our open collective:
> https://opencollective.com/husky/donate

$ HUSKY_DEBUG=1 git commit # ...

We had to roll back to Husky v3 due to the issue about hooks not getting called when using VS Code's Git client (which most of the team is using). However, this issue occurred on that as well as on our current version (3.1.0).

I'm unsure if this is a husky issue or something else, but on pre-push, we execute all of our unit tests with jest, and then if it passes, push up to origin. However, as we continue to build out tests, these take longer and longer and it seems like when the tests take somewhere in the 52-54sec or more range, then the push just never occurs even though the tests all passed. Our pre-commit hook, which is much faster works fine, and if the tests take less than 52secs, it pushes fine as well.

Here is our husky config:

	"husky": {
		"hooks": {
			"post-merge": "npm run setup",
			"pre-commit": "lint-staged",
			"pre-push": "npm run test:no-watch"
		}
	},

and here is the test:no-watch script:

		"test:no-watch": "cross-env CI=true REACT_APP_ENV=testing TZ=America/Chicago npm test -- --env=jsdom"

Anything else I can provide, I would be happy to do so, but the repo is private so cannot share that. The actual output when it works or fails is no different, other than when it works I see the push occur after the tests. Thanks!

@typicode
Copy link
Owner

typicode commented Apr 9, 2020

Hi @bduff9,

It's strange, not sure what's happening. I would try adding a HUSKY_DEBUG=1 env variable to VSCode and check if https://github.com/typicode/husky/blob/master/sh/husky.sh#L16 is logged.

If you see it, it means that npm run test:no-watch has finished executing. Otherwise for some reasons npm run test:no-watch is not ending.

I've also just released v4.2.4, it's closer to v3 regarding the shell used for running hooks.

@bduff9
Copy link
Author

bduff9 commented Apr 9, 2020

Thanks for the reply. I just tried 4.2.4, but unfortunately, get the same issue with npx not being found:

Can't find npx in PATH: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin
Skipping pre-commit hook

As far as this issue, I can add the HUSKY_DEBUG to my ZSH session, but what do you mean about adding it to VSCode? Is there a way to add an env var that the Git client will pick up?

@typicode
Copy link
Owner

typicode commented Apr 9, 2020

Is there a way to add an env var that the Git client will pick up?

I don't have VSCode installed currently, but I'd expect there would be a way. Alternatively, you could add it to ~/.huskyrc:

export HUSKY_DEBUG=1

You would have debug messages after husky reads it.

get the same issue with npx not being found

For this issue, if you're using a Node version manager (like nvm), try to load it in ~/.huskyrc
https://github.com/typicode/husky#local-commands-huskyrc

@bduff9
Copy link
Author

bduff9 commented Apr 10, 2020

For this issue, if you're using a Node version manager (like nvm), try to load it in ~/.huskyrc
https://github.com/typicode/husky#local-commands-huskyrc

I added the location of npx to my path in .huskyrc and this seems to work for me on the latest (4.2.5). I also added the debug so I will report back here as soon as I see this push issue occur again. Thank you

@bduff9
Copy link
Author

bduff9 commented Apr 10, 2020

Ha, actually first push this issue happened again.

...
Test Suites: 138 passed, 138 total
Tests:       420 passed, 420 total
Snapshots:   162 passed, 162 total
Time:        57.383s
Ran all test suites.
husky:debug npx --no-install husky-run exited with 0 exit code

So looks like it is exiting but push still did not happen. Here is a successful push that I ran right after it:

...
Test Suites: 138 passed, 138 total
Tests:       420 passed, 420 total
Snapshots:   162 passed, 162 total
Time:        52.819s
Ran all test suites.
husky:debug npx --no-install husky-run exited with 0 exit code
Enumerating objects: 35, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), 2.53 KiB | 152.00 KiB/s, done.
Total 17 (delta 10), reused 0 (delta 0)
To bitbucket.org:project.git
   9f42c33cc..a527c0085  develop -> develop

@bduff9
Copy link
Author

bduff9 commented Apr 17, 2020

@typicode Hi, any more thoughts or things I can try on this? Still happening quite frequently with the latest version of Husky (about 1 out of every 2 or 3 times we push). The output is always the same as above. Happy to provide any more details needed to help figure this issue out. Thanks!

@MaxPenderuk
Copy link

@bduff9 Hi, I was experiencing the same issue till today. But in my case, I was not able to push stuff without --no-verify at all. The colleague of mine said that it is my SSH connection hanging up. It can be fixed by increasing the timeout or setting it up so that it won't time out at all. Try this. It helped me.

@bduff9
Copy link
Author

bduff9 commented May 29, 2020

@MaxPenderuk Thanks so much, I just added the keep alive to my config. I will test it out over the next week and report back. Thanks again!

@jfaylon
Copy link

jfaylon commented Jun 24, 2020

Having the same issue here; tried increasing the ssh timeout but no luck. This may be due to the tests taking too long. Is there a way husky can handle such?

@christo8989
Copy link

I'm having similar issues. I also tried increasing the timeout with no luck. :/

@stale
Copy link

stale bot commented Jul 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 2, 2021
@stale stale bot closed this as completed Jul 9, 2021
@paulogc
Copy link

paulogc commented Oct 14, 2021

I've been facing this issue recently, the timeout config also didn't help.

@omerg
Copy link

omerg commented Feb 10, 2022

Our team is facing this issue randomly as well.

@mankutila
Copy link

Also is the case

@YaroslavAntipov358
Copy link

Same for me.

@alanPaivaaspOctos
Copy link

same

1 similar comment
@joshcove
Copy link

same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests