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

Youtube Video Upload Stuck in Deno Runtime #560

Open
dogukanakkaya opened this issue Jun 18, 2024 · 0 comments
Open

Youtube Video Upload Stuck in Deno Runtime #560

dogukanakkaya opened this issue Jun 18, 2024 · 0 comments
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@dogukanakkaya
Copy link

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.

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.

@dogukanakkaya dogukanakkaya added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants