diff --git a/.changeset/eight-hotels-try.md b/.changeset/eight-hotels-try.md new file mode 100644 index 000000000000..f1fab2897d1f --- /dev/null +++ b/.changeset/eight-hotels-try.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Disables streaming when rendering site with `output: "static"` diff --git a/packages/astro/src/core/build/pipeline.ts b/packages/astro/src/core/build/pipeline.ts index a89aa10f071c..245904660c18 100644 --- a/packages/astro/src/core/build/pipeline.ts +++ b/packages/astro/src/core/build/pipeline.ts @@ -53,7 +53,8 @@ export class BuildPipeline extends Pipeline { return assetLink; } const serverLike = isServerLikeOutput(config); - const streaming = true; + // We can skip streaming in SSG for performance as writing as strings are faster + const streaming = serverLike; super( options.logger, manifest, diff --git a/packages/astro/src/runtime/server/render/astro/render.ts b/packages/astro/src/runtime/server/render/astro/render.ts index 37a78725a092..f918f55c11dc 100644 --- a/packages/astro/src/runtime/server/render/astro/render.ts +++ b/packages/astro/src/runtime/server/render/astro/render.ts @@ -31,6 +31,10 @@ export async function renderToString( let str = ''; let renderedFirstPageChunk = false; + if (isPage) { + await bufferHeadContent(result); + } + const destination: RenderDestination = { write(chunk) { // Automatic doctype insertion for pages diff --git a/packages/astro/test/content-collections-render.test.js b/packages/astro/test/content-collections-render.test.js index 0e8e37fb176b..277ef8c06956 100644 --- a/packages/astro/test/content-collections-render.test.js +++ b/packages/astro/test/content-collections-render.test.js @@ -2,11 +2,7 @@ import * as assert from 'node:assert/strict'; import { after, before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; import testAdapter from './test-adapter.js'; -import { isWindows, loadFixture } from './test-utils.js'; - -if (!isWindows) { - describe(); -} +import { loadFixture } from './test-utils.js'; describe('Content Collections - render()', () => { describe('Build - SSG', () => {