gabrielcsapo / node-git-server

🎡 A configurable git server written in Node.js
https://gabrielcsapo.github.io/node-git-server
MIT License
253 stars 73 forks source link

Push finished event #40

Closed rafaelcorreiapoli closed 5 years ago

rafaelcorreiapoli commented 6 years ago

Hi! How can I know when the push has finished sending all data? The current event for push is triggered before all data is sent to the server

gabrielcsapo commented 5 years ago

push.on('response', stream => { }); should give you a state in which all the data has been received by the server.

gabrielcsapo commented 5 years ago

Closing, if you have any other questions let me know!

h110m commented 3 years ago

@gabrielcsapo @rafaelcorreiapoli

push.on('response', () => {}) doesn't work that well i tried it because i needed to execute another git command right after the push that was async i tried it with the response listener but it just hung up the whole "end rsp" cycle and the client which pushed the changes also hung up because the server didn't respond anymore

My final solution was to wait for the response to finish and then execute my command

You can do this with

push.res.on("finish", () => {
    // execute stuff
});
push.accept();

Just put this inside the repos on push listener and you are good to go ^-^