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

Packing go binaries prevents entry callback from being called #64

Closed
alexdavid opened this issue Dec 23, 2016 · 5 comments
Closed

Packing go binaries prevents entry callback from being called #64

alexdavid opened this issue Dec 23, 2016 · 5 comments

Comments

@alexdavid
Copy link

This is the strangest bug, but I've narrowed it down to go binaries. tar-stream seems to silently fail to add them. Anything else I add to the tar works fine.

Steps to reproduce:

Create file test.go:

package main

import "fmt"

func main() {
	fmt.Println("test")
}

Build go file:

$ go build test.go

Create file test.js:

var fs = require("fs");
var tar = require('tar-stream');

var fileName = "./test";
var pack = tar.pack();


fs.stat(fileName, function (err, stat) {
    if (err) {
        return console.log(err);
    }

    var packOptions = {
        mode: stat.mode,
        mtime: stat.mtime,
        name: 'test',
        size: stat.size
    };

    var rs = fs.createReadStream(fileName);
    var entry = pack.entry(packOptions, function (err) {
        console.log("This happens");
        pack.finalize();
    });
    console.log("We pipe the stream here and expect a callback...");
    return rs.pipe(entry);
});

Expected result: This happens gets logged and the pack is finalized.
Actual result: This happens is never logged and pack is not finalized

@mafintosh
Copy link
Owner

could you share the binary file that is causing trouble? don't have go installed

@alexdavid
Copy link
Author

Sorry for the late reply. Here's a link to the binary that is not behaving:

http://ipfs.io/ipfs/QmbWN6wpsuSwTrVNWX2nwGCM9ZqnPSzNYc3hUZACKANWiR

@mgcrea
Copy link

mgcrea commented Nov 30, 2017

Not sure if this has anything to do with a go binary, similar code hangs for me as well as soon as I'm trying to pipe a readStream into an entry, in my case it's large mock buffer filled with 1.

@mafintosh
Copy link
Owner

@mgcrea can you share a test case?

@diamondap
Copy link
Contributor

I ran into this issue as well while trying to extract Go binaries from a tar archive I had created with tar-stream. Further tests showed other large files, such as Mac .dmg files, had the same problem. I did find a workaround, which I posted here:

https://gist.github.com/diamondap/b6b36dd50e1e94e2bbe89a221124eb76

This issue does not seem to affect normal read streams, only PassThrough streams. All of the large binary files I tried to extract failed before this workaround, and they all work after.

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

4 participants