bahmutov / bahmutov/pre-git

stdout maxBuffer exceeded when running pre-push hook

Open
#46 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
170
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Hi Gleb,

I am using your library to create hooks for git. Kudos for the good work. I am getting an error though:

`pre-push Failed to check for commits. Cannot run the tests.`
`pre-push [Error: stdout maxBuffer exceeded.]`

I think this is due to the limitation of the stdout maxBuffer that Nodejs defaults to 200KB, see https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback.

I have verified that the command is causing trouble is

`git diff --name-only origin/master..HEAD`

I committed by mistake my node_modules folder and now I want to remove it from my repository. Obviously, the list of files is big and the command above produces a lot of text. I could increase the maxBuffer but I have read the article on http://www.hacksparrow.com/difference-between-spawn-and-exec-of-node-js-child_process.html that does not recommend to do that. What do you think? Do you have anything against using spawn rather than exec to create the child process?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the pre-push hook runs `git diff --name-only origin/master..HEAD`, then consult the Node.js child_process documentation for the current exec and spawn behavior. Done means the hook handles large command output without the reported stdout maxBuffer error while preserving its existing commit checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.