Repository: sveltejs/kit
Pull request #6247 (2022-08-25 00:03:53)

increase timeout to a silly number
seeing a lot of timeouts on the safari tests for some reason, possibly a combination of the machine being underpowered and the AMP validator being a steaming turd

changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: 10e218d6a7444670c49e670a98a3c04a0f2f69c4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/sveltejs/kit/new/increase-timeout?filename=.changeset/stupid-guests-hunt.md&value=---%0A%22%40sveltejs%2Fkit%22%3A%20patch%0A%22test-amp%22%3A%20patch%0A---%0A%0Aincrease%20timeout%20to%20a%20silly%20number%0A)



Patch:
diff --git a/.changeset/strong-cooks-run.md b/.changeset/strong-cooks-run.md
new file mode 100644
index 000000000..18b6984a3
--- /dev/null
+++ b/.changeset/strong-cooks-run.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+[fix] only generate blank non-SSR pages when prerendering is enabled
diff --git a/packages/kit/src/runtime/server/page/index.js b/packages/kit/src/runtime/server/page/index.js
index ebe1f005d..737943603 100644
--- a/packages/kit/src/runtime/server/page/index.js
+++ b/packages/kit/src/runtime/server/page/index.js
@@ -104,6 +104,27 @@ export async function render_page(event, route, page, options, state, resolve_op
 		const should_prerender_data = nodes.some((node) => node?.server);
 		const data_pathname = `${event.url.pathname.replace(/\/$/, '')}/__data.json`;
 
+		// it's crucial that we do this before returning the non-SSR response, otherwise
+		// SvelteKit will erroneously believe that the path has been prerendered,
+		// causing functions to be omitted from the manifesst generated later
+		const should_prerender =
+			leaf_node.shared?.prerender ?? leaf_node.server?.prerender ?? options.prerender.default;
+		if (should_prerender) {
+			const mod = leaf_node.server;
+			if (mod && (mod.POST || mod.PUT || mod.DELETE || mod.PATCH)) {
+				throw new Error('Cannot prerender pages that have endpoints with mutative methods');
+			}
+		} else if (state.prerendering) {
+			// if the page isn't marked as prerenderable (or is explicitly
+			// marked NOT prerenderable, if `prerender.default` is `true`),
+			// then bail out at this point
+			if (!should_prerender) {
+				return new Response(undefined, {
+					status: 204
+				});
+			}
+		}
+
 		if (!resolve_opts.ssr) {
 			return await render_response({
 				branch: [],
@@ -123,24 +144,6 @@ export async function render_page(event, route, page, options, state, resolve_op
 			});
 		}
 
-		const should_prerender =
-			leaf_node.shared?.prerender ?? leaf_node.server?.prerender ?? options.prerender.default;
-		if (should_prerender) {
-			const mod = leaf_node.server;
-			if (mod && (mod.POST || mod.PUT || mod.DELETE || mod.PATCH)) {
-				throw new Error('Cannot prerender pages that have endpoints with mutative methods');
-			}
-		} else if (state.prerendering) {
-			// if the page isn't marked as prerenderable (or is explicitly
-			// marked NOT prerenderable, if `prerender.default` is `true`),
-			// then bail out at this point
-			if (!should_prerender) {
-				return new Response(undefined, {
-					status: 204
-				});
-			}
-		}
-
 		/** @type {Array<Loaded | null>} */
 		let branch = [];
 


Test patch:
diff --git a/packages/kit/test/apps/amp/playwright.config.js b/packages/kit/test/apps/amp/playwright.config.js
index e83b1fd33..e97e615a6 100644
--- a/packages/kit/test/apps/amp/playwright.config.js
+++ b/packages/kit/test/apps/amp/playwright.config.js
@@ -1,6 +1,6 @@
 import { config } from '../../utils.js';
 
-config.webServer && (config.webServer.timeout = 15000); // AMP validator needs a long time to get moving
+config.webServer && (config.webServer.timeout = 45000); // AMP validator needs a long time to get moving
 
 // remove any projects with javaScriptEnabled
 const projects = config.projects || [];