MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / scaleProtocolTimeoutForComposition

Function scaleProtocolTimeoutForComposition

packages/engine/src/config.ts:285–300  ·  view source on GitHub ↗
(
  baseTimeoutMs: number,
  dims: { width: number; height: number },
)

Source from the content-addressed store, hash-verified

283 * for tests.
284 */
285export function scaleProtocolTimeoutForComposition(
286 baseTimeoutMs: number,
287 dims: { width: number; height: number },
288): number {
289 const { width, height } = dims;
290 if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
291 return baseTimeoutMs;
292 }
293 const factor = (width * height) / PROTOCOL_TIMEOUT_REFERENCE_PIXELS;
294 if (factor <= 1) return baseTimeoutMs;
295 const scaled = Math.ceil(baseTimeoutMs * factor);
296 // Ceiling is `max(base, MAX)` so an explicit base above the ceiling is never
297 // lowered (preserves the "only ever raise" contract for all callers).
298 const ceiling = Math.max(baseTimeoutMs, MAX_SCALED_PROTOCOL_TIMEOUT_MS);
299 return Math.min(ceiling, Math.max(baseTimeoutMs, scaled));
300}
301
302function memoryAdaptiveCacheLimit(): number {
303 const total = getSystemTotalMb();

Callers 2

executeRenderJobFunction · 0.90
config.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected