DIRECTcut / ytb--down

A simple web app to download youtube videos with a URL
0 stars 0 forks source link

App hangs when an unavailable video is requested #2

Closed DIRECTcut closed 3 years ago

DIRECTcut commented 3 years ago

Expected Behavior

When an unavailable video is requested, the server catches an Error and sends it to the client as JSON.

Current Behavior

When an unavailable video is requested, the server emits an Error. The app hangs without exceptions.

Possible Solution

Catch errors on ytdl.getInfo() (/api/info route) and send them to the client;

Steps to Reproduce

  1. Open the app
  2. Paste an unavailable video's link (https://www.youtube.com/watch?v=U_RAWwgCwS1)
  3. Press 'Submit'

Context (Environment)

Detailed Description

Possible Implementation

status header: 404,

{
  "error": {
    "message": "Video unavailable",
  }
}
DIRECTcut commented 3 years ago

Was able to catch errors on '/api/info' endpoint. Attempts to do the same on '/api/download' did not succeed, get the following error (server-side):

(node:10456) UnhandledPromiseRejectionWarning: Error: Video unavailable
    at Object.exports.playError (C:\Users\DIRECTcut\Documents\GitHub\DIRECTcut\vid_downloader\node_modules\ytdl-core\lib\util.js:458:12)
    at exports.getBasicInfo (C:\Users\DIRECTcut\Documents\GitHub\DIRECTcut\vid_downloader\node_modules\ytdl-core\lib\info.js:85:22)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Map.getOrSet (C:\Users\DIRECTcut\Documents\GitHub\DIRECTcut\vid_downloader\node_modules\ytdl-core\lib\cache.js:24:19)
    at async exports.getInfo (C:\Users\DIRECTcut\Documents\GitHub\DIRECTcut\vid_downloader\node_modules\ytdl-core\lib\info.js:226:14)
    at async Map.getOrSet (C:\Users\DIRECTcut\Documents\GitHub\DIRECTcut\vid_downloader\node_modules\ytdl-core\lib\cache.js:24:19)
(node:10456) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by 
rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10456) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
DIRECTcut commented 3 years ago

Fixed in commit