Repository navigation
Docs: Note that bundle() does not delete its temporary directory - #13665
Draft
conorbronsdon wants to merge 1 commit into
Draft
conorbronsdon wants to merge 1 commit into
conorbronsdon wants to merge 1 commit into
Conversation
Without `outDir`, `bundle()` creates a `remotion-webpack-bundle-*` folder in `os.tmpdir()` and never removes it. Say so under `outDir` and show deleting the returned path after rendering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
outDiris not passed,bundle()creates a newremotion-webpack-bundle-*folder inos.tmpdir()and nothing deletes it. The CLI removes its bundle through its ownonDirectoryCreatedcleanup hook, but the Node.js API docs don't say that callers have to do this themselves.We hit this in a pipeline that called
bundle()once per render (the anti-pattern the page already warns about). It left 1,970 stale bundle folders, 81 GB in total, in%TEMP%on Windows. Bundling once avoids most of it, but the one bundle still stays on disk after the process exits.Changes to
packages/docs/docs/bundle.mdx:outDir?: say the temporary directory is not deleted, and link to the return value section.outDiris not passed, with an example that bundles once, renders, and deletes the returned path in afinallyblock.How this was checked against the source at 6a07b17:
packages/bundler/src/bundle.tsL43-L52:prepareOutDir()callsfs.promises.mkdtemp(path.join(os.tmpdir(), 'remotion-webpack-bundle-'))when nooutDiris given.internalBundle()returns that path at L486 and never removes it.packages/cli/src/render-flows/render.tsL375-L378: the CLI registersRenderInternals.deleteDirectory(dir)fromonDirectoryCreated, which is why CLI renders don't leak.@remotion/lambda: Clean up generated site bundles #9569 added the same kind of cleanup for the bundles that LambdadeploySite()generates.The snippet uses the same imports and call shapes as the example in
ssr-node.mdx. I couldn't run the docs build locally (this machine has Bun 1.3.14 and the repo requires 1.4.3 or later), so the twoslash block has not been type-checked.oxfmt@0.35.0 --checkwith the repo's.oxfmtrc.jsonpasses on the changed file.The example uses the return value rather than
onDirectoryCreated. That means abundle()call that throws partway through can still leave its folder behind. I left that case out to keep the note short.🤖 Generated with Claude Code