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

I can't download files larger than 70KB to my Google Cloud Storage bucket #2370

Closed
PatricioPoncini opened this issue Nov 27, 2023 · 7 comments
Assignees
Labels
alt runtimes Questions / issues for non-Node runtimes api: storage Issues related to the googleapis/nodejs-storage API. type: question Request for information or clarification. Not an issue.

Comments

@PatricioPoncini
Copy link

I'm having an issue with GCS and Bun. It turns out that I want to download an image from my bucket, and I'm encountering an error. I'm using the .download() method from the GCS library, but it gives me an error for files larger than a certain size in KB.

This worked fine in Express, but when doing it in Bun, it doesn't, and I don't know why. What I'm trying to do is pass an array of public URLs that I have in my bucket, download them, and send them by email. However, for files larger than approximately 70KB, it doesn't work because the code stops, and nothing gets sent. I'm getting the following errors:

262 | 'ECONNREFUSED',
263 | ].includes(err.code))) {
264 | let code = 'UNKNOWN';
265 | if (err.code)
266 | code = err.code;
267 | process.emitWarning(`received unexpected error = ${err.message} code = ${code}`, 'MetadataLookupWarning');
^
warn: received unexpected error = Was there a typo in the URL or port? code = FailedToOpenSocket
at /mnt/c/Users/user/Desktop/proyect/node_modules/gcp-metadata/build/src/index.js:267:16
at processTicksAndRejections (:61:76)

11 | // Since node 6.3.0 state.buffer is a BufferList not an array
12 | if (state.buffer.head) {
13 | return state.buffer.head.data.length
14 | }
15 |
16 | return state.buffer[0].length
               ^
TypeError: undefined is not an object (evaluating 'state.buffer[0].length')
at getStateLength (/mnt/c/Users/user/Desktop/proyect/node_modules/stream-shift/index.js:16:11)
at shift (/mnt/c/Users/user/Desktop/proyect/node_modules/stream-shift/index.js:6:98)
at /mnt/c/Users/user/Desktop/proyect/node_modules/duplexify/index.js:170:34
at onreadable (/mnt/c/Users/user/Desktop/proyect/node_modules/duplexify/index.js:136:4)
at processTicksAndRejections (:61:76)

I'm not sure what these errors refer to. I've tried updating the library, dependencies, etc., but nothing seems to work. The error seems to have occurred when I switched from Express to Bun because it used to work perfectly fine before.

This is the line, with files larger than approximately 70KB, it doesn't go beyond this line, meaning it doesn't download them: const downloadResponse = await findFile.download();

@PatricioPoncini PatricioPoncini added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Nov 27, 2023
@PatricioPoncini PatricioPoncini changed the title I can't upload files larger than 70KB to my Google Cloud Storage bucket I can't download files larger than 70KB to my Google Cloud Storage bucket Nov 27, 2023
@ddelgrosso1
Copy link
Contributor

Hi @PatricioPoncini unfortunately at this time we do not have official support for Bun. This library was written / intended for Node environments. We are currently investigating the possibility of expanding support to other runtimes but there is no time frame for when / if this will happen.

@ddelgrosso1 ddelgrosso1 self-assigned this Nov 27, 2023
@PatricioPoncini
Copy link
Author

Hi @ddelgrosso1 nice to meet you. Do you know if there is any other way to use the npm library google-cloud/storage in a project with Bun? Specifically, it's with Bun and ElysiaJS the project. Thank you!

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Nov 27, 2023
@ddelgrosso1 ddelgrosso1 added alt runtimes Questions / issues for non-Node runtimes and removed api: storage Issues related to the googleapis/nodejs-storage API. labels Nov 27, 2023
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Nov 28, 2023
@ddelgrosso1
Copy link
Contributor

@PatricioPoncini unfortunately my testing with Bun has been fairly limited at this point. I've actually spent more time investigating Deno. So I'm not sure how to get this working with Bun.

Just looking at the stack trace you provided the problem seems to be coming from Duplexify which is one of our dependencies. It might be worth opening an issue with that repository. I noted this on another similar issue, we are planning to move away from Duplexify in the next major revision to storage but I wouldn't expect that to happen until sometime next year.

@PatricioPoncini
Copy link
Author

@ddelgrosso1 No problem, thanks anyway. Cheers!

@charlesbodman
Copy link

Same error occurs on node 20

@ddelgrosso1
Copy link
Contributor

@charlesbodman if you are seeing this issue on a supported Node version can you please open a new issue with additional details?

@ddelgrosso1 ddelgrosso1 removed the priority: p3 Desirable enhancement or fix. May not be included in next release. label May 16, 2024
@ddelgrosso1
Copy link
Contributor

Going to close this as I believe this has been resolved (at least for Node). At this time we do not support environments other than Node. If this is still an issue for Node, please feel free to open a new issue with additional details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alt runtimes Questions / issues for non-Node runtimes api: storage Issues related to the googleapis/nodejs-storage API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants