{"record":{"id":"62af9477ba76ea5f","repo":"remotion-dev/remotion","slug":"onmodelloadprogress-must-be-a-function","errorCode":null,"errorMessage":"onModelLoadProgress must be a function.","messagePattern":"onModelLoadProgress must be a function\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/separate-video-layers.ts","lineNumber":232,"sourceCode":"\t\t\toptions.keyframeIntervalInSeconds <= 0)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'keyframeIntervalInSeconds must be a positive finite number.',\n\t\t);\n\t}\n\n\tif (\n\t\toptions.onProgress !== undefined &&\n\t\ttypeof options.onProgress !== 'function'\n\t) {\n\t\tthrow new TypeError('onProgress must be a function.');\n\t}\n\n\tif (\n\t\toptions.onModelLoadProgress !== undefined &&\n\t\ttypeof options.onModelLoadProgress !== 'function'\n\t) {\n\t\tthrow new TypeError('onModelLoadProgress must be a function.');\n\t}\n};\n\nconst makeInput = (src: string | URL | Blob): Input => {\n\tconst source =\n\t\ttypeof src === 'string' || src instanceof URL\n\t\t\t? new UrlSource(src)\n\t\t\t: new BlobSource(src);\n\n\treturn new Input({formats: ALL_FORMATS, source});\n};\n\nconst probeVideoInput = async ({\n\tinput,\n\tvideoQuality,\n}: {\n\tinput: Input;\n\tvideoQuality: Quality;","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/separate-video-layers.ts#L214-L250","documentation":"separateVideoLayers validates its options before doing any work. If you pass onModelLoadProgress and it is not a function (and not undefined), a TypeError is thrown immediately during option validation. This callback is supposed to receive model download/loading progress (0-1), so anything other than a callable would silently break progress reporting, hence the strict check.","triggerScenarios":"Calling separateVideoLayers({src, onModelLoadProgress: <non-function>}) — e.g. onModelLoadProgress: true, a string, a number, or null (null is not undefined, so it fails the check).","commonSituations":"Passing null intending 'no callback'; passing a promise-returning value or a config object instead of the callback; typo like onModelLoadProgres leaving a stale value; reading the option from untyped config/JSON input.","solutions":["Remove the onModelLoadProgress property entirely if you don't need progress reporting (undefined is allowed).","Pass an actual function, e.g. (progress) => console.log(progress).","If the value comes from user config, default it: onModelLoadProgress: cfg.cb ?? undefined, and reject non-function config values before calling."],"exampleFix":"// before\nawait separateVideoLayers({src, onModelLoadProgress: null});\n// after\nawait separateVideoLayers({\n  src,\n  onModelLoadProgress: (progress) => setProgress(progress),\n});","handlingStrategy":"validation","validationCode":"if (opts.onModelLoadProgress !== undefined && typeof opts.onModelLoadProgress !== 'function') {\n  throw new TypeError('onModelLoadProgress must be a function or undefined');\n}","typeGuard":"const isProgressCb = (v: unknown): v is (p: number) => void =>\n  typeof v === 'function';","tryCatchPattern":null,"preventionTips":["Never pass null for optional callbacks — omit the key instead.","Rely on the SeparateVideoLayersOptions TypeScript type to catch non-function values at compile time.","Validate user-supplied config objects before spreading them into options."],"tags":["validation","options","callback","typeerror"],"backgroundTag":"invalid-argument-value","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}