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

Uncaught in promise #407

Closed
yafp opened this issue Jan 10, 2020 · 4 comments
Closed

Uncaught in promise #407

yafp opened this issue Jan 10, 2020 · 4 comments

Comments

@yafp
Copy link

yafp commented Jan 10, 2020

Hi

i am working on a project which is using node-youtube-dl.

node-youtube-dl again seems to use execa (3.2.0) to execute the download - at least if the user is using the .exec function.

In some cases i end up with the following error output

C:\Users\X\AppData\Local\Temp\1WCEOMbi5OoghDvt6WrxHGmrqcQ\resources\app\node_modules\execa\lib\error.js:56 
Uncaught (in promise) Error: Command failed with exit code 1: C:\Users\X\AppData\Local\Temp\1WCEOMbi5OoghDvt6WrxHGmrqcQ\resources\app\node_modules\youtube-dl\bin\youtube-dl --format best --output C:\Users\X\Downloads\Video\%(title)s-%(id)s.%(ext)s --add-metadata --ignore-errors --encoding utf8 http://www.youtube.com/watch?v=90AiXO1pAiA
at makeError (C:\Users\X\AppData\Local\Temp\1WCEOMbi5OoghDvt6WrxHGmrqcQ\resources\app\node_modules\execa\lib\error.js:56)
at handlePromise (C:\Users\X\AppData\Local\Temp\1WCEOMbi5OoghDvt6WrxHGmrqcQ\resources\app\node_modules\execa\index.js:114)
at processTicksAndRejections (internal/process/task_queues.js:85)

error.js:

if (error instanceof Error) {
		error.originalMessage = error.message;
		error.message = `${message}\n${error.message}`;
	} else {
		error = new Error(message); // line 56
	}

index.js:

if (error || exitCode !== 0 || signal !== null) {
			const returnedError = makeError({ // line 114
				error,
				exitCode,
				signal,
				stdout,
				stderr,
				all,
				command,
				parsed,
				timedOut,
				isCanceled: context.isCanceled,
				killed: spawned.killed
			});

Any ideas on that issue? I'm open for any input ;)
For me it seems like it fails often on Windows and by far not that often on linux machines (if that helps)

See a more detailed version of my issue here: przemyslawpluta/node-youtube-dl#284

@ehmicky
Copy link
Collaborator

ehmicky commented Jan 13, 2020

Hi @yafp, thanks for reaching out.

Could you please post a sample of the lines calling Execa?

Also, what happens when you run the following command directly in cmd.exe (please replace path\to with the appropriate path)?

C:\path\to\youtube-dl --format best --output C:\path\to\%(title)s-%(id)s.%(ext)s --add-metadata --ignore-errors --encoding utf8 http://www.youtube.com/watch?v=90AiXO1pAiA

@yafp
Copy link
Author

yafp commented Jan 13, 2020

Hi @ehmicky
first of all - thanks for your feedback.

regarding how node-youtube-dl is using execa:

It seems like the only use is in /lib/youtube-dl.js.

'use strict'

const universalify = require('universalify')
const streamify = require('streamify')
const request = require('request')
const hms = require('hh-mm-ss')
const http = require('http')
const url = require('url')

const {
  isYouTubeRegex,
  isWin,
  formatDuration,
  has,
  isString
} = require('./util')

let ytdlBinary = require('./get-binary')()

const execa = universalify.fromPromise(require('execa'))

function youtubeDl (args, options, cb) {
  return execa(ytdlBinary, args, options, function done (err, output) {
    if (err) return cb(err)
    return cb(null, output.stdout.trim().split(/\r?\n/))
  })
}

I'll check what happens if executed directly in the coming days.

@ehmicky
Copy link
Collaborator

ehmicky commented Jan 13, 2020

It looks to me that the problem is not in Execa itself but in the command being executed itself. For example, if instead of using Execa, child_process.spawn() was used instead, this would still error.

This could be due to either the command used by node-youtube-dl, or the argument you are passing to it. One way to better analyze this would be to:

  • execute the shell command in a terminal and see if that command errors
  • isolate the execa() call from the rest of node-youtube-dl to provide with a minimally reproducible example

@yafp yafp closed this as completed Jan 16, 2020
@dustinvo17
Copy link

Hi @yafp, I'm currently facing the same issue like this. Did you manage to solve this? If yes, would you please kindly walk me through your approach?
I greatly appreciate your help!
Thank you

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

3 participants