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

fix: eager exiting to prevent hung state #1090

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

laggingreflex
Copy link

Possible fix for #1089. I know it's a hacky solution, so not exactly hoping to get merged, but just to show where the problem exists.

It parses the data (on(data)) and exists eagerly without having to wait for the exit event - which is what's causing #1089

fixes #1089

@federicocarboni
Copy link

It seems that fluent-ffmpeg is no longer maintained, but I'd be curious to understand what causes the issue. I couldn't replicate it, unfortunately (even on Windows 10). What I thought initially was a possible deadlock with the std streams but it doesn't seem to be the case. @laggingreflex did you manage to find what's the underlying problem? It would be easier to find a less "hacky" fix.

@laggingreflex
Copy link
Author

laggingreflex commented Dec 12, 2020

@federicocarboni Thanks for the reply!

I haven't found the root cause.

Another solution (than this fix) that works for me is if I use a retry function (with a timeout).

I've been using ffmpeg and this library in a project for a long time and this has only occurred on a particular setup - a large set of video files (150k files, 2.7TB) on a USB HDD. I should add that there were also bad sectors on this HDD that I repaired (chkdsk) earlier. My project involves ffprobe-ing a lot of those files and a lot of them have been failing seemingly randomly. I'm suspecting this whole particular setup (the HDD and/or act of probing a lot of files) might have something to do with it. Since I can't even seem to reproduce the issue on same files that failed when I try again.

PS: I tried your library (eloquent-ffmpeg) as well - same issue (fails randomly, works on retrying).

@federicocarboni
Copy link

@laggingreflex
Does stdout emit the close event even when it gets stuck? If it does, a cleaner solution would just be to move the code that's currently running on exit into stdout's close, and since we already have ffprobe's output on close we can just kill ffprobe if it hasn't exited already.
The issue is difficult to reproduce so I just added my best guess.

CI tests seem to be failing because mocha was updated and it no longer supports Node.js 8, which is a test target for this project.

@laggingreflex
Copy link
Author

Does stdout emit the close event even when it gets stuck?

It doesn't. Just "data" event. Here's what console.log(ffmpegProcess) looks like: https://gist.github.com/laggingreflex/252585944ea4369efadc37076aed6fdc

  _eventsCount: 2,
  _maxListeners: undefined,
  _closesNeeded: 3,
  _closesGot: 0, << if this is a counter for close events, none received
  connected: false,
  signalCode: null,

(it's after a 5000ms timeout)

The issue is difficult to reproduce so I just added my best guess.

Definitely. Please feel free to give any other debugging pointers, I'll try them out.

Or I'll update if I come across anything more useful.

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

Successfully merging this pull request may close these issues.

ffprobe hangs
2 participants