Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up content layer sync in build and sync api #12633

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-teachers-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Cleans up content layer sync during builds and programmatic `sync()` calls
1 change: 1 addition & 0 deletions packages/astro/src/core/dev/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export async function createContainer({
logger,
skip: {
content: true,
cleanup: true,
},
force: inlineConfig?.force,
manifest,
Expand Down
6 changes: 6 additions & 0 deletions packages/astro/src/core/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export type SyncOptions = {
skip?: {
// Must be skipped in dev
content?: boolean;
// Cleanup can be skipped in dev as some state can be reused on updates
cleanup?: boolean;
};
manifest: ManifestData;
};
Expand Down Expand Up @@ -141,6 +143,10 @@ export async function syncInternal({
store,
});
await contentLayer.sync();
if (!skip?.cleanup) {
// Free up memory (usually in builds since we only need to use this once)
contentLayer.dispose();
}
settings.timer.end('Sync content layer');
} else {
const paths = getContentPaths(settings.config, fs);
Expand Down
Loading