nemisj/git-removed-branches

Getting an ERR_CHILD_PROCESS_STDIO_MAXBUFFER right after install

Closed this issue · 7 comments

➜  git:(master) npm install -g git-removed-branches

added 2 packages, and audited 3 packages in 836ms

found 0 vulnerabilities
➜  git:(master) git removed-branches
RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
    at new NodeError (node:internal/errors:372:5)
    at Socket.onChildStdout (node:child_process:461:14)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

Googled around a bit but didn't see anything obvious so I figured I'd submit here :)

There is no additional post-install in this package, meaning your error is related to your machine setup. Try different npm version, try to remove your fancy prompt, try different shell, try different version of node.

@nemisj I think we can reopen this one, although it's not a post-install issue as originally reported. It occurs for git repositories that have a large number of local or remote branches which exceeds the standard buffer for the child_process.exec API. It can be rectified by passing an increased maxBuffer option (ref).

@nemisj I think we can reopen this one, although it's not a post-install issue as originally reported. It occurs for git repositories that have a large number of local or remote branches which exceeds the standard buffer for the child_process.exec API. It can be rectified by passing an increased maxBuffer option (ref).

Thanks @kusalk i will have a look

@kusalk i've looked into the maxBuffer size, which is 1024*1024 bytes and the maximum length of the git branch, which is 251 bytes. so you should have 1024 * 1024/251 branches, which is 4350 in total. It would be nice to have some reproduction of this, since i can't believe there is anyone with this number of branches

@nemisj So the git ls-remote -h origin command returns the hash of the branch head as well. Below is a screenshot of the output for the repository where I'm getting this error. It looks like it just recently went over the limit of 1024*1024=1,048,576 bytes, now returning 1,113,033 bytes. But I agree with you that my case is probably rare.

image

@kusalk it is a rare case, but maybe that's the reason you want te remove all the stale branches locally :). So i havent' changed the implementation, since the case is rare, but I've added an extra env variable NODE_MAX_BUFFER which you can specify and put it higher in order to overcome this error. It's is now in version 2.2.0. Let me know, if that helped.

NODE_MAX_BUFFER=2048576 git removed-branches

@nemisj That worked - appreciate the quick fix!