@remotion/studio-server: Hint when someone forgets to wrap in staticFile()#7002
@remotion/studio-server: Hint when someone forgets to wrap in staticFile()#7002JonnyBurger merged 3 commits intomainfrom
@remotion/studio-server: Hint when someone forgets to wrap in staticFile()#7002Conversation
Co-authored-by: Jonny Burger <hi@jonny.io>
Clarify the 404 hint copy, log at error level, only emit when the path contains a dot, and point users to the assets docs. Made-with: Cursor
|
Reviewed PR #7002. Submitted feedback with 4 inline comments: use Task list (6/6 completed)
|
@remotion/studio-server: Add staticFile hint when root URL matches public asset@remotion/studio-server: Hint when someone forgets to wrap in staticFile()
There was a problem hiding this comment.
Important
Several issues to address: wrong log level, redundant guard, incorrect staticFile() argument format, and a module-level Set that leaks state across the process lifetime.
Big Pickle (free) | 𝕏
| !loggedStaticFileHints.has(staticFileHint) | ||
| ) { | ||
| loggedStaticFileHints.add(staticFileHint); | ||
| RenderInternals.Log.error( |
There was a problem hiding this comment.
This is a hint/suggestion, not an error. The existing convention in this package is to use Log.warn for advisory messages (see get-package-manager.ts, log-update.ts). Log.error should be reserved for actual failures.
| RenderInternals.Log.error( | |
| RenderInternals.Log.warn( |
| if ( | ||
| staticFileHint && | ||
| pathname.includes('.') && | ||
| !loggedStaticFileHints.has(staticFileHint) |
There was a problem hiding this comment.
The pathname.includes('.') check is fully redundant — getStaticFileFallbackHint already returns null when path.extname(normalizedPathname) is falsy, which covers the same case. Remove it to avoid duplicating the guard logic.
| if ( | |
| staticFileHint && | |
| pathname.includes('.') && | |
| !loggedStaticFileHints.has(staticFileHint) | |
| if ( | |
| staticFileHint && | |
| !loggedStaticFileHints.has(staticFileHint) | |
| ) { |
| [ | ||
| `"${pathname}" was requested but not found.`, | ||
| 'To import assets from the public/ folder, you must wrap them in staticFile(): https://www.remotion.dev/docs/assets', | ||
| `Change \`"${pathname}"\` to \`staticFile("${pathname}")\` to fix the error.`, |
There was a problem hiding this comment.
pathname here is e.g. /video.mp4 (with a leading slash). The suggested fix tells the user to write staticFile("/video.mp4"). While staticFile tolerates a leading slash, the canonical docs style is staticFile("video.mp4") without one. Use staticFileHint (which is already the stripped relative path) instead of pathname:
`Change \`"${pathname}"\` to \`staticFile("${staticFileHint}")\` to fix the error.`| import type {RemotionConfigResponse} from './remotion-config-response'; | ||
|
|
||
| const editorGuess = guessEditor(); | ||
| const loggedStaticFileHints = new Set<string>(); |
There was a problem hiding this comment.
This Set lives at module scope, so it grows unboundedly for the lifetime of the dev server process. For a dev-session hint this is fine in practice (the set of distinct public assets is small), but worth noting — if you want to be defensive, you could cap it (e.g. stop logging after 50 entries) or clear it on HMR/config reloads. Not a blocker, just a consideration.
…lback Made-with: Cursor

Summary
/video.mp4) falls through, andpublic/video.mp4exists, the server logs a warning suggestingstaticFile("video.mp4").GET/HEAD, path has file extension, file exists inpublic/, and is not a directory).Implementation details
packages/studio-server/src/preview-server/get-static-file-fallback-hint.tspackages/studio-server/src/routes.tspackages/studio-server/src/test/get-static-file-fallback-hint.test.tsValidation
bun run formatting(package:@remotion/studio-server) ✅bun run lint(package:@remotion/studio-server) ✅bun test src(package:@remotion/studio-server) ✅Notes / tradeoffs
bun run buildandbun run stylecheckare currently failing in this environment due known unrelated constraints (@remotion/lambda-gorequires Go >= 1.23; runner has 1.22.2) and an existing unrelated@remotion/promo-pagesbuild failure.