Skip to content

test(engine): cover spawnStreamingEncoder lifecycle and cleanup paths#380

Merged
vanceingalls merged 1 commit intomainfrom
vance/streaming-encoder-lifecycle-tests
Apr 23, 2026
Merged

test(engine): cover spawnStreamingEncoder lifecycle and cleanup paths#380
vanceingalls merged 1 commit intomainfrom
vance/streaming-encoder-lifecycle-tests

Conversation

@vanceingalls
Copy link
Copy Markdown
Collaborator

@vanceingalls vanceingalls commented Apr 21, 2026

Summary

Add unit tests that mock child_process.spawn to drive an in-memory "ffmpeg" through the success/failure paths used by the producer's HDR encoder and by Chunk 5A's defensive close() in renderOrchestrator.

Why

Chunk 9D of plans/hdr-followups.md. The contracts the orchestrator's try/finally cleanup (Chunk 5A) and the abort path rely on were entirely uncovered. A regression in spawnStreamingEncoder's lifecycle handling would surface as a leaked ffmpeg process or a hung render, both of which are hard to diagnose after the fact.

What changed

packages/engine/src/services/streamingEncoder.test.ts: 7 new specs covering:

  • Successful exit after explicit close().
  • Non-zero exit before close() returns a failure result (no throw).
  • ENOENT on spawn returns a failure result (no throw).
  • Abort signal triggers SIGTERM and a "cancelled" result.
  • close() is idempotent and never throws on a second call.
  • writeFrame returns false after the encoder has exited.
  • close() detaches the abort listener so post-close aborts don't re-kill ffmpeg.

These contracts are what the renderOrchestrator try/finally cleanup added in Chunk 5A relies on, and what the ffprobe-unavailable test (Chunk 9B) hinted at for the encoder side.

Test plan

  • All new specs pass.
  • No production code changes — pure regression coverage of existing lifecycle behavior.

Stack

Chunk 9D of plans/hdr-followups.md. Test-only change, complements Chunk 5A.

Copy link
Copy Markdown
Collaborator Author

vanceingalls commented Apr 21, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 0294c06 to cc0422f Compare April 21, 2026 20:48
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from 469db85 to ae2d4a7 Compare April 21, 2026 20:48
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from cc0422f to 8638446 Compare April 21, 2026 20:54
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from ae2d4a7 to 5f4e626 Compare April 21, 2026 20:54
@vanceingalls vanceingalls marked this pull request as ready for review April 21, 2026 20:57
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 8638446 to dad30f7 Compare April 21, 2026 22:37
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch 2 times, most recently from cbdf78d to ca75d84 Compare April 22, 2026 01:16
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from dad30f7 to b3cd341 Compare April 22, 2026 01:16
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 4b1cbf9 to f2464f3 Compare April 23, 2026 01:58
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from adc776e to 143a1db Compare April 23, 2026 01:58
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from f2464f3 to 72f4d29 Compare April 23, 2026 02:57
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from 143a1db to 6ece916 Compare April 23, 2026 02:58
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 72f4d29 to 2196dec Compare April 23, 2026 03:20
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from 6ece916 to e638a99 Compare April 23, 2026 03:21
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 2196dec to 2c19da9 Compare April 23, 2026 03:42
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from e638a99 to 5fb85c5 Compare April 23, 2026 03:42
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 2c19da9 to 40e2154 Compare April 23, 2026 04:50
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from 5fb85c5 to d84c3ea Compare April 23, 2026 04:50
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 40e2154 to efe5bcb Compare April 23, 2026 05:10
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from d84c3ea to 4b68ca4 Compare April 23, 2026 05:10
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from efe5bcb to 633de87 Compare April 23, 2026 05:45
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from 4b68ca4 to 4be516a Compare April 23, 2026 05:46
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 633de87 to ef05bfc Compare April 23, 2026 06:07
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from 4be516a to 5a225bf Compare April 23, 2026 06:07
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from ef05bfc to 1b05a9e Compare April 23, 2026 06:58
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch 2 times, most recently from c7fcca8 to bc1bac0 Compare April 23, 2026 15:33
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch 2 times, most recently from 4c7b80a to 5512a6a Compare April 23, 2026 16:33
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from bc1bac0 to 7d56ccc Compare April 23, 2026 16:34
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from 5512a6a to c0836ce Compare April 23, 2026 16:35
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from 7d56ccc to 5262779 Compare April 23, 2026 16:35
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch from c0836ce to f82f2cb Compare April 23, 2026 17:38
@vanceingalls vanceingalls force-pushed the vance/streaming-encoder-lifecycle-tests branch from 5262779 to 49ca88b Compare April 23, 2026 17:39
@vanceingalls vanceingalls force-pushed the vance/ffprobe-fallback-tests branch 2 times, most recently from 3aca369 to f5be292 Compare April 23, 2026 18:12
Add unit tests that mock child_process.spawn so we can drive an in-memory
'ffmpeg' through the success/failure paths used by the producer's HDR encoder
and by Chunk 5A's defensive close() in renderOrchestrator.

Covers:
- successful exit after explicit close()
- non-zero exit before close() returns a failure result (no throw)
- ENOENT on spawn returns a failure result (no throw)
- abort signal triggers SIGTERM and a 'cancelled' result
- close() is idempotent and never throws on a second call
- writeFrame returns false after the encoder has exited
- close() detaches the abort listener so post-close aborts don't re-kill ffmpeg

These contracts are what the renderOrchestrator try/finally cleanup added in
Chunk 5A relies on, and what the ffprobe-unavailable test (Chunk 9B) hinted at
for the encoder side.
Copy link
Copy Markdown
Collaborator Author

Merge activity

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.

2 participants