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

Adding an option to disable HTTP streaming #3777

Merged
merged 18 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
moving config to build.streaming, ignoring it in dev
  • Loading branch information
Tony Sullivan committed Jun 30, 2022
commit 693adf2ae85b769b75f2bfde31a3521998786ff3
18 changes: 18 additions & 0 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,24 @@ export interface AstroUserConfig {
* ```
*/
format?: 'file' | 'directory';
/**
* @docs
* @name build.streaming
* @typeraw {boolean}
* @default `true`
* @description
* Controls whether HTTP streaming is used in SSR production builds.
*
* ```js
* {
* build: {
* // Example: Disable HTTP streaming in production SSR builds.
* streaming: false
* }
* }
* ```
*/
streaming?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think I can actually remove this completely if we don't want dev or preview support!

};

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async function generatePath(
? new URL(astroConfig.base, astroConfig.site).toString()
: astroConfig.site,
ssr,
streaming: astroConfig.server.streaming,
streaming: astroConfig.build.streaming,
};

let body: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const AstroConfigSchema = z.object({
.union([z.literal('file'), z.literal('directory')])
.optional()
.default(ASTRO_CONFIG_DEFAULTS.build.format),
streaming: z.boolean().optional().default(true),
})
.optional()
.default({}),
Expand All @@ -155,7 +156,6 @@ export const AstroConfigSchema = z.object({
.optional()
.default(ASTRO_CONFIG_DEFAULTS.server.host),
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
streaming: z.boolean().optional().default(true),
})
.optional()
.default({})
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/render/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export async function render(
routeCache,
site: astroConfig.site ? new URL(astroConfig.base, astroConfig.site).toString() : undefined,
ssr: isBuildingToSSR(astroConfig),
streaming: astroConfig.server.streaming,
streaming: true,
});

return response;
Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/core/render/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
const url = new URL(request.url);
const canonicalURL = createCanonicalURL('.' + pathname, site ?? url.origin, paginated);
const headers = new Headers();
console.log('createResult', args.streaming);
if (args.streaming) {
headers.set('Transfer-Encoding', 'chunked');
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function createIntegration(): AstroIntegration {
hooks: {
'astro:config:setup': ({ updateConfig }) => {
updateConfig({
server: {
build: {
streaming: false
}
});
Expand Down