Complete stable playback and proxy safeguards - #184
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The transcode integration fixture currently sets FFMPEG_PATH to the Node executable (which cannot accept ffmpeg flags), and the SIGKILL escalation guard in stopWorker prevents forced termination from ever triggering.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR aims to make playback resilient to channel renames by propagating a stable sourceChannelId through source sync, output/playback surfaces (including MCP and admin preview), and it strengthens reverse-proxy trust handling plus transcoding worker safeguards.
Changes:
- Propagate persistent
sourceChannelIdfromsource_channelsinto in-memory snapshots and consumers (MCP, output profiles, admin preview). - Add integration coverage for stable source-channel playback and explicit reverse-proxy trust behavior.
- Harden transcoding process lifecycle (timeouts, backpressure handling, shutdown escalation) and update test fixtures.
File summaries
| File | Description |
|---|---|
| test/integration/transcode.test.js | Updates transcoding integration fixtures to avoid shell wrappers and exercise error/success cases. |
| test/integration/parseM3U-sqlite.test.js | Asserts channel snapshots persist the durable sourceChannelId. |
| test/integration/output-profile-routes.test.js | Adds an end-to-end assertion that stable /stream/channel/:id URLs remain playable after renames. |
| test/integration/mcp.test.js | Extends MCP list_channels payload expectations to include sourceChannelId. |
| test/integration/improvements.test.js | Adds reverse-proxy trust tests to ensure forged forwarded headers are ignored unless explicitly trusted. |
| server/transcode.js | Adds bounded config parsing, stronger spawn failure handling, backpressure support, and worker shutdown escalation. |
| server/mcp.js | Exposes sourceChannelId in list_channels output for stable agent playback URLs. |
| scripts/parseM3U.js | Copies persisted sourceChannelId from source sync into the mapped channel snapshot. |
| libs/source-sync-service.js | Returns a lookup of persisted source-channel IDs and stamps sourceChannelId onto discovered channels. |
| admin/src/App.vue | Switches preview routes to prefer /.../channel/:sourceChannelId when available, falling back to legacy routes. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+38
to
+42
| function setFfmpegStub(stub, originalNodeOptions) { | ||
| process.env.FFMPEG_PATH = process.execPath; | ||
| process.env.FFMPEG_STUB_CONFIG = JSON.stringify(stub.options); | ||
| process.env.NODE_OPTIONS = `${originalNodeOptions || ''} --require ${JSON.stringify(stub.preloadPath)}`.trim(); | ||
| } |
Comment on lines
+145
to
+149
| // SIGTERM is advisory on Windows. Escalate so a stalled upstream cannot | ||
| // retain an expensive encoder worker indefinitely. | ||
| forceKillTimer = setTimeout(() => { | ||
| if (ffmpegProcess.exitCode === null && !ffmpegProcess.killed) ffmpegProcess.kill('SIGKILL'); | ||
| }, KILL_GRACE_MS); |
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.
Summary
Fixes #167
Fixes #170
Fixes #177
Validation