fix(build): disable prerender crawl so build stops OOMing
`/hikes` is `prerender = true` and carries the global nav, so the prerender crawler followed those links and tried to statically render the whole dynamic, DB-/ML-backed app. SvelteKit prerenders inside a heap-capped worker_threads worker, so this exhausted its heap (ERR_WORKER_OUT_OF_MEMORY) and failed the build. - svelte.config.js: prerender.crawl = false. The intended static set is fully described by `prerender = true` (/hikes) + the /errors/[status] EntryGenerator, so crawling is unneeded. Add a defensive handleHttpError that ignores /hikes/*/images/* 404s (those binaries live in hikes-assets/, served by nginx/dev-middleware, not /static). - hooks.server.ts: skip init when `building` so builds don't connect to Mongo, start the payment scheduler, or warm the romcal cache. - hikes/[slug]: set `prerender = false`, enforcing the intent its comment already stated. Version 1.86.1 -> 1.86.2.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { Handle, HandleServerError, ServerInit } from "@sveltejs/kit"
|
||||
import { redirect } from "@sveltejs/kit"
|
||||
import { sequence } from "@sveltejs/kit/hooks"
|
||||
import { building } from "$app/environment"
|
||||
import * as auth from "./auth"
|
||||
import { initializeScheduler } from "./lib/server/scheduler"
|
||||
import { dbConnect } from "./utils/db"
|
||||
@@ -122,6 +123,15 @@ async function timing({ event, resolve }: Parameters<Handle>[0]) {
|
||||
}
|
||||
|
||||
export const init: ServerInit = async () => {
|
||||
// SvelteKit runs prerendering/analysis inside a worker_threads worker (see
|
||||
// @sveltejs/kit utils/fork.js) whose JS heap is capped well below the main
|
||||
// thread's. `init` fires there too, so warming the romcal cache during a
|
||||
// build exhausts that worker's heap → ERR_WORKER_OUT_OF_MEMORY and a failed
|
||||
// build. None of it is needed at build time: no prerendered route touches the
|
||||
// DB, and connecting to Mongo / starting the payment scheduler from a build
|
||||
// is undesirable regardless. Skip startup work while building.
|
||||
if (building) return;
|
||||
|
||||
console.log('🚀 Server starting - initializing database connection...');
|
||||
try {
|
||||
await dbConnect();
|
||||
|
||||
Reference in New Issue
Block a user