Files
SnapOtter/tests/unit/media-engine/ffmpeg-input-classification.test.ts
T
SnapOtterandGitHub ae6a4c8b7c fix: error-only Sentry telemetry, storm-proof capture, and crash fixes (#476)
Removes Sentry tracing entirely (BullMQ idle polling burned 4.8M transactions in 2 days at the baked 0.1 rate), decouples PostHog sampling, and replaces the type-only error scrub with a vetted-field sanitizer plus SafeError/ToolInputError contracts. One classified capture path with per-signature throttles and a per-process ceiling makes storms impossible (NODE-1E was 4,541 events from one 30s loop). Browser errors move to a dedicated web Sentry project with their own source maps. Adds the SNAPOTTER_TELEMETRY runtime kill switch and silences test fleets.

Crash fixes: remote 204/304 SSRF process kill (NODE-20), conversion-preset boot crash loop (NODE-21), Redis version preflight + unhandled subscribe rejection (NODE-1T), Sign PDF on plain-http origins (NODE-1K/1M), wavesurfer/pdf.js teardown rejections (NODE-1P/1N), bundle-import ZlibError to 400 (NODE-1Z), chart-maker input errors declassified (NODE-1H/1J), asset requests skip the session DB lookup (NODE-1D).
2026-07-10 21:41:49 +08:00

45 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { markIfInputError } from "../../../packages/media-engine/src/ffmpeg.js";
type MaybeMarked = Error & { isToolInputError?: unknown };
describe("markIfInputError", () => {
it("marks the error when stderr reports no packets received", () => {
const err = new Error("ffmpeg exited 1: tail of stderr");
const result = markIfInputError(
err,
"Finishing stream without any data written to it.\nOutput received no packets",
) as MaybeMarked;
expect(result).toBe(err);
expect(result.isToolInputError).toBe(true);
expect(result.message).toBe("ffmpeg exited 1: tail of stderr");
});
it("marks the other known input-failure stderr shapes, case-insensitively", () => {
const shapes = [
"input.mp4: Invalid data found when processing input",
"Could not find codec parameters for stream 0",
"[mov,mp4,m4a,3gp,3g2,mj2] moov atom not found",
"OUTPUT RECEIVED NO PACKETS",
];
for (const stderr of shapes) {
const marked = markIfInputError(new Error("ffmpeg exited 1: x"), stderr) as MaybeMarked;
expect(marked.isToolInputError, stderr).toBe(true);
}
});
it("leaves unrelated stderr unmarked", () => {
const err = markIfInputError(
new Error("ffmpeg exited 1: tail of stderr"),
"Error while opening encoder: some libx264 build issue",
) as MaybeMarked;
expect(err.isToolInputError).toBeUndefined();
expect(err.message).toBe("ffmpeg exited 1: tail of stderr");
});
it("leaves empty stderr unmarked", () => {
const err = markIfInputError(new Error("ffmpeg exited 1: "), "") as MaybeMarked;
expect(err.isToolInputError).toBeUndefined();
});
});