Summary
screencast_start validates the requested file extension with a case-sensitive endsWith() against ['.webm', '.mp4'] and silently falls back to .mp4 when nothing matches, instead of erroring. Combined with ensureExtension() (which replaces the existing extension), the recording can be written in a different format and to a different path than requested, with no warning.
(Reported originally by @ch-bas while testing; filing upstream with a reproduction and a fix.)
Affected code
src/tools/screencast.ts — the supportedExtensions loop uses filePath.endsWith(supportedExtension) (case-sensitive) with a silent .mp4 default.
src/utils/files.ts — ensureExtension() strips the existing extension via path.extname and appends the enforced one.
Present in v1.2.0 and on current main (the two files are unchanged between them).
Steps to reproduce
- Start the server with
--experimentalScreencast=true (and --experimentalFfmpegPath <ffmpeg>).
screencast_start with filePath: "demo.WEBM".
screencast_stop.
Actual
Records MP4 to demo.mp4 — neither the requested format nor the requested path. The same happens for any unsupported extension, e.g. recording.avi silently becomes recording.mp4.
Reproduced with the exact endsWith loop + ensureExtension run through node:path:
| requested |
resolved path |
format |
|
demo.webm |
demo.webm |
webm |
ok |
demo.WEBM |
demo.mp4 |
mp4 |
wrong |
demo.Webm |
demo.mp4 |
mp4 |
wrong |
recording.avi |
recording.mp4 |
mp4 |
wrong |
clip.MP4 |
clip.mp4 |
mp4 |
silently renamed |
Expected
.WEBM / .Webm etc. treated as WebM (case-insensitive match).
- An explicitly requested but unsupported extension rejected with an explicit error listing the supported formats, rather than silently switching format and path.
Minor related issue
When screencast_start is called without a filePath, it creates a temp directory via mkdtemp(). If page.screencast() then throws (e.g. ffmpeg missing), that directory is never cleaned up, leaking an empty temp dir per failed attempt.
Fix
PR incoming that (1) matches the extension case-insensitively, (2) rejects unsupported explicit extensions with a clear error, and (3) removes the generated temp directory when recording fails to start. Includes regression tests using the existing screencast test harness.
Environment
chrome-devtools-mcp v1.2.0 / current main.
Summary
screencast_startvalidates the requested file extension with a case-sensitiveendsWith()against['.webm', '.mp4']and silently falls back to.mp4when nothing matches, instead of erroring. Combined withensureExtension()(which replaces the existing extension), the recording can be written in a different format and to a different path than requested, with no warning.(Reported originally by @ch-bas while testing; filing upstream with a reproduction and a fix.)
Affected code
src/tools/screencast.ts— thesupportedExtensionsloop usesfilePath.endsWith(supportedExtension)(case-sensitive) with a silent.mp4default.src/utils/files.ts—ensureExtension()strips the existing extension viapath.extnameand appends the enforced one.Present in
v1.2.0and on currentmain(the two files are unchanged between them).Steps to reproduce
--experimentalScreencast=true(and--experimentalFfmpegPath <ffmpeg>).screencast_startwithfilePath: "demo.WEBM".screencast_stop.Actual
Records MP4 to
demo.mp4— neither the requested format nor the requested path. The same happens for any unsupported extension, e.g.recording.avisilently becomesrecording.mp4.Reproduced with the exact
endsWithloop +ensureExtensionrun throughnode:path:demo.webmdemo.webmdemo.WEBMdemo.mp4demo.Webmdemo.mp4recording.avirecording.mp4clip.MP4clip.mp4Expected
.WEBM/.Webmetc. treated as WebM (case-insensitive match).Minor related issue
When
screencast_startis called without afilePath, it creates a temp directory viamkdtemp(). Ifpage.screencast()then throws (e.g. ffmpeg missing), that directory is never cleaned up, leaking an empty temp dir per failed attempt.Fix
PR incoming that (1) matches the extension case-insensitively, (2) rejects unsupported explicit extensions with a clear error, and (3) removes the generated temp directory when recording fails to start. Includes regression tests using the existing screencast test harness.
Environment
chrome-devtools-mcpv1.2.0 / currentmain.