googleapis / googleapis/google-cloud-node

Youtube Video Upload Stuck in Deno Runtime

Open
#7,709 0 comments 0 reactions 1 assignee Claimed by @sofisl View on GitHub
library: google-cloud-node-core priority: p3 type: feature request
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

When uploading videos using the `googleapis` sdk in Deno Runtime, video uploads stuck at some point. I've tried with several videos with different sizes. One is stuck at %61, other is %18 etc. Never completes, progresses quickly at first but once stuck, never starts again.

```ts
import { google } from 'npm:googleapis';
import fs from 'node:fs'

const filePath = `file.mp4`;
const fileSize = Deno.statSync(filePath).size;

// new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]); credentials also assigned after oauth flow completed
const auth = await getOAuthClient()
const youtube = google.youtube({ version: 'v3', auth });

return youtube.videos.insert({
part: ['snippet', 'status'],
requestBody: {
snippet: {
title,
description: `#shorts ${tags.join(' ')}`,
tags: ['shorts', ...tags],
categoryId: '24',
defaultLanguage: 'en'
},
status: {
privacyStatus: 'private'
},
},
media: {
body: fs.createReadStream(filePath)
}
}, {
onUploadProgress: evt => {
const progress = (evt.bytesRead / fileSize) * 100;
console.log(`${Math.round(progress)}% complete`);
},
size: fileSize
})

/*
Uploading video
4% complete
7% complete
11% complete
15% complete
18% complete
*/
// stuck after that and no more progressing
```

I do think something about file streaming doesn't work as expected in Deno. I don't have time to deep dive into what's wrong but I do think this should be fixed in this SDK itself rather than Deno hence opening this issue in this repository. It'd be great if `insert` function is compatible with all JS runtimes instead of being Node dependent.

Trying this in Bun Runtime can also shed more light on what's the issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.