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

repo.unpack callback is never called using HTTP transport #120

Open
whyleee opened this issue Aug 9, 2015 · 7 comments
Open

repo.unpack callback is never called using HTTP transport #120

whyleee opened this issue Aug 9, 2015 · 7 comments

Comments

@whyleee
Copy link

whyleee commented Aug 9, 2015

Tested in my code and your clone-test repo: TCP transport works well, but HTTP transport freezes at 99% and never calls the callback. It actually receives and saves all the data, but somehow doesn't call the callback after that. I tried to debug, but it's hard for me to understand where the problem is.
Note: I use this code for Node.js HTTPS request implementation, because XHR doesn't work with GitHub. But I don't think this code is related to the problem.
Could you please run the code in your clone-test repo and see if you have the same problem with cloning HTTPS urls? Or maybe you have ideas why the callback is not called?

@techniq
Copy link

techniq commented Sep 14, 2015

@creationix any ideas?

@creationix
Copy link
Owner

Sorry, I haven't looked at this in quite a while. I do remember that clone-test was working over XHR (as long as I installed the browser extension to inject the CORS headers). It is possible that your code has a bug though I can't see it right away.

I've never seen that trick of using Buffer.concat in the data loop (I usually build a normal array and then concat once inside end), but I think your style should work fine as well.

It's also possible that something in js-git broke since I was testing clone-test. Maybe compare the last date I pushed to clone-test with the date of the last js-git and related publishes?

@jauco
Copy link

jauco commented Mar 30, 2016

I can reproduce this bug. @whyleee it seems you have fixed this bug in whyleee/nogit#7 what was the fix?

@jauco
Copy link

jauco commented Apr 1, 2016

It might have broken when you switched to culvert, or it might only break on certain data streams.

What happens is that at the end the onSave method calls channel.take(onRead) when the channel is empty. (https://github.com/creationix/js-git/blob/master/mixins/pack-ops.js#L129 ) This puts the onRead callback on the readQueue in culvert (https://github.com/creationix/culvert/blob/master/channel.js#L59 ). However the readQueue will not be touched until someone adds some new data to the stream (which won't happen because all data was already pushed to the stream).

It looks like I need to add a method to culvert to close a channel right? and then have the users of culvert use that method. @creationix is that correct?

@creationix
Copy link
Owner

Sounds good I think. Like I said before, I haven't touched this code in years.

@whyleee
Copy link
Author

whyleee commented Apr 5, 2016

@jauco I haven't really fixed this issue, I just used regex for progress output to find the last chunk 😄 whyleee/nogit@8dfcb01#diff-f8fba8b03f3acaae3ecdcdbb453e0d7d

@fabrixxm
Copy link

worked after I changed line 92 in lib/pack-codec.js:

- if (!state) return;
+ if (!state) { if(checksum.length===40) emit(); return; }

It works, but could be wrong...

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

No branches or pull requests

5 participants