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

PHP - Retry conformance in Google\Cloud\Storage\StorageClient breaks streaming large files using registerStreamWrapper #7473

Closed
bogdanstoik opened this issue Jun 25, 2024 · 5 comments

Comments

@bogdanstoik
Copy link

Code:

$storage = new StorageClient([
	'projectId' => ...,
	'keyFile' => ...,
]);
$storage->registerStreamWrapper();
$f = fopen('gs://path/to/very/large/file', 'r');

Before commit a8211f2:
code runs fast (<1s, regardless file size or connection speed). $f is referencing a readable stream and can be used without fully downloading the file

After commit a8211f2:
code runs slow (depending on file size and connection speed), the file is fully downloaded on the client machine. $f is referencing a readable stream from the local file

Possible cause: in vendor/google/cloud-storage/src/Connection/Rest.php:350
Utils::copyToStream($fetchedStream, $resultStream);
makes a full download of the stream, since registerStreamWrapper doesn't manage ['restOptions']['headers']['Range']

@bshaffer
Copy link
Contributor

bshaffer commented Jul 1, 2024

Thank you for filing this issue, and for your thorough research into the problem. I will take a look at this and see if I can't identify the issue.

@bshaffer
Copy link
Contributor

bshaffer commented Jul 2, 2024

@bogdanstoik I created a fix here. You can install it with composer by doing something like:

composer require google/cloud: dev-fix-storage-streamwrapper as 0.500.0

It will be in this week's release or next week, but we'd love to have you test it first to ensure it fixes your issue specifically!

@bogdanstoik
Copy link
Author

I can confirm the patch fixes my specific issue. Thank you so much for the quick response!

@bshaffer
Copy link
Contributor

bshaffer commented Jul 3, 2024

@bogdanstoik thank YOU for notifying us of the problem and providing such a detailed issue as to make it easier to track down.

@bshaffer
Copy link
Contributor

bshaffer commented Jul 8, 2024

This is now fixed in google/cloud-storage: 1.42.1

@bshaffer bshaffer closed this as completed Jul 8, 2024
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

2 participants