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

gcloud writestreams no longer working when piping stdout from GraphicsMagick #889

Closed
jseeley78 opened this issue Sep 23, 2015 · 6 comments
Closed
Assignees

Comments

@jseeley78
Copy link

GraphicsMagick lib:
http://aheckmann.github.io/gm/

ex:

var gm = require('gm').subClass({ imageMagick: true }),
      src = '/src/file.jpg',
      dst = myBucket.file('file.png');

var wr = dst.createWriteStream();

gm(src)
    .setFormat('png')
    .stream(function(err, stdout, stderr) {
    if (err) return cb(err);
    // pipe output to writestream
    stdout.pipe(wr);
    wr.on("error", function(err) {
        return cb(err);
    });
     wr.on("finish", function() {
        return cb();
    });
});

works in release 20 and older(using complete event); breaks in release 21, finish doesn't seem to trigger, error is fired with->
{ [Error: The uploaded data did not match the data from the server. As a precaution, the file has been deleted. To be sure the content is the same, you should try uploading the file again.] code: 'FILE_NO_UPLOAD', errors: [ null ] }

@stephenplusplus
Copy link
Contributor

Thanks! I'll look into this right away.

@stephenplusplus
Copy link
Contributor

I was able to use the same code and get the file to upload successfully. finish won't emit because error does, and it's an error because somehow, the hash of the bytes that were sent upstream aren't matching what the API says it received.

To get around this, you can turn off validation, or limit it to a specific type. Playing with these options might help debugging where the problem is happening.

To do that:

// Turn off all data integrity checks
var wr = dst.createWriteStream({ validation: false });

// Use just md5
var wr = dst.createWriteStream({ validation: 'md5' });

// Use just crc32c
var wr = dst.createWriteStream({ validation: 'crc32c' });

If you try this, please let me know which worked (if any), and confirm that the file that ended up in the bucket is properly formed.

@jseeley78
Copy link
Author

this seems odd but->

validation: false (fails)
validation: true (succeeds)
validation: 'md5' (succeeds)
validation: 'crc32c' (succeeds)

@stephenplusplus
Copy link
Contributor

I think I caught the bug, though I'm not sure why it failed succeeded when you explicitly provided validation: true, as that's what is defaulted.

Can you try out my patch branch to see if it works:

$ npm install --save stephenplusplus/gcloud-node#spp--storage-stream-fix

@jseeley78
Copy link
Author

I can see why it would have failed when validation is set to false, but like you said the validation default is true when you don't specify... (and why would the stdout stream from GraphicsMagick make any difference?) ANYWAY... this fix works ;-)

@stephenplusplus
Copy link
Contributor

Yeah, weird. Well, PR coming soon after I write some tests. Thanks for letting us know about this issue!

sofisl pushed a commit that referenced this issue Jan 17, 2023
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/186c39d8-938f-497c-8229-46ff7b78fe4d/targets

- [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.)

Source-Link: googleapis/synthtool@c6706ee
Source-Link: googleapis/synthtool@b33b0e2
Source-Link: googleapis/synthtool@898b38a
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

3 participants