j-holub / Node-MPV

A NodeJs Module for MPV Player
https://www.npmjs.com/package/node-mpv
MIT License
117 stars 73 forks source link

UnhandledPromiseRejection on seek #89

Open dave12311 opened 3 years ago

dave12311 commented 3 years ago

Bug Description

Calling the seek() function while there is no file loaded causes uncaught UnhandledPromiseRejection exception.

How To Reproduce

Create an mpv instance and call seek without loading a file first.

Expected behavior

Calling an invalid seek should reject the promise returned by the seek() function

Software Versions
Additional context

Quick fix with:

observeSocket.connect({path: this.options.socket}, async () => {
    try {
        await this.command('seek', [seconds, mode, 'exact']);
    } catch (e) {
        reject(e);
    }
})
j-holub commented 3 years ago

Hey there,

I'm sorry for only seeing this just now, Thanks for noticing, this is indeed something that shouldn't happen, as it's so simple. If you want to, you can make a PR or I can make the fix, up to you : )

Cheers

husudosu commented 2 years ago

If it's okay I'm gonna do the PR request. It's been a year since the issue opened.