-
Notifications
You must be signed in to change notification settings - Fork 109
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
files.download
doesn't properly wait until the operation finished. So it is impossible to read the file immediately after downloading it.
After reading the code. I believe it is a bug with the NodeDownloader.download
method.
https://github.com/googleapis/js-genai/blob/main/src/node/_node_downloader.ts#L30
There is a PR trying to fix this but it didn't fix all the branches in download
function. We also need to properly wait for the pipeline to finish. I drafted a PR to fix this branch.
Environment details
- Programming language: TypeScript
- OS: MacOS
- Language runtime version: Node.js 22
- Package version: 1.10.0
Steps to reproduce
- use
files.download
download to download a file - read the file immediately using an async API.
- notice the file size doesn't reflect the actual file size.
// we are using await here but it doesn't wait until the file is finished being written.
await gemini.files.download({
file: video, // for example a generated video
"/tmp/video.mp4",
});
fs.stat(downloadPath, (err, file) => {
console.log(file.size); // the size is not complete
});
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.