Skip to content

Commit

Permalink
Disable streaming for SSG (withastro#10796)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored and PeterDraex committed Apr 23, 2024
1 parent b0aba11 commit 26ca2fd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-hotels-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Disables streaming when rendering site with `output: "static"`
3 changes: 2 additions & 1 deletion packages/astro/src/core/build/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions packages/astro/src/runtime/server/render/astro/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions packages/astro/test/content-collections-render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 26ca2fd

Please sign in to comment.