fix(engine): track and time-bound ffprobe spawns#1576
Open
calcarazgre646 wants to merge 1 commit into
Open
Conversation
runFfprobe was the only engine child-process spawn without trackChildProcess or a timeout. Every other spawn (runFfmpeg, the chunk and streaming encoders, the frame extractor) registers with the process tracker and bounds itself with a timeout. A hung ffprobe (malformed container, stalled network FS, a fifo) therefore never settled, and killTrackedProcesses() on render abort/teardown could not reap it since it was never in the tracked set. analyzeKeyframeIntervals is the worst case: it probes every keyframe and can run long. Register the child with trackChildProcess and add a 120s timeout that SIGTERMs and rejects, mirroring runFfmpeg.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
runFfprobe(ffprobe.ts) was the only engine child-process spawn withouttrackChildProcessor a timeout. Every other spawn (runFfmpeg, the chunk and streaming encoders, the frame extractor) registers with the process tracker and bounds itself with a timeout. So a hung ffprobe (malformed container, stalled network filesystem, a fifo) never settled, andkillTrackedProcesses()on render abort/teardown could not reap it because it was never in the tracked set.analyzeKeyframeIntervalsis the worst case: it probes every keyframe and can run long.Change
Register the child with
trackChildProcessand add a 120s timeout that SIGTERMs and rejects, mirroringrunFfmpeg. The 120s bound is generous for the slowest legitimate probe while capping a true hang.gpuEncoder's spawns are one-shot, cached capability detection with their own timeout and SIGKILL grace, not render-pipeline probes over untrusted input, so they are intentionally out of scope here.Tests
A timeout test: a hung ffprobe is killed and rejects after the timeout instead of leaking. Verified load-bearing (reverting the fix makes the test hang to the vitest timeout). Full engine suite green (743 tests).