sveltejs/kit · warning

Cloudflare Pages Functions' includes/excludes exceeds _route

Error message

Cloudflare Pages Functions' includes/excludes exceeds _routes.json limits (see https://developers.cloudflare.com/pages/platform/functions/routing/#limits). Dropping ${excess} exclude rules — this will cause unnecessary function invocations.

What it means

Cloudflare Pages' _routes.json allows at most 100 combined include/exclude rules. get_routes_json in the Cloudflare adapter de-duplicates the generated rules and, when the total exceeds 100, drops exclude rules from the end so the file stays valid. Dropped excludes mean those paths will match an include pattern and invoke the Functions script unnecessarily, costing extra invocations.

Source

Thrown at packages/adapter-cloudflare/utils.js:153

		}

		if (rule === '<prerendered>') {
			builder.prerendered.paths.forEach((path) => excluded_routes.add(path));
			continue;
		}

		if (rule === '<redirects>') {
			redirects.forEach((path) => excluded_routes.add(path));
			continue;
		}

		excluded_routes.add(rule);
	}
	exclude = Array.from(excluded_routes);

	const excess = include.length + exclude.length - 100;
	if (excess > 0) {
		builder.log.warn(
			`Cloudflare Pages Functions' includes/excludes exceeds _routes.json limits (see https://developers.cloudflare.com/pages/platform/functions/routing/#limits). Dropping ${excess} exclude rules — this will cause unnecessary function invocations.`
		);
		exclude.length -= excess;
	}

	return {
		version: 1,
		description: 'Generated by @sveltejs/adapter-cloudflare',
		include,
		exclude
	};
}

/**
 * Adds header rules to the contents of a `_headers` file
 * @param {string} url
 * @param {string[]} rules
 * @param {string} content

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Reduce the number of routes or broaden include/exclude patterns so the total stays under 100.
  2. Prerender more routes so they are excluded by fewer, broader patterns instead of many specific ones.
  3. Consolidate static assets into fewer directories and exclude those directories wholesale.
  4. Accept the dropped rules if the extra function invocations are tolerable (the build still succeeds).

Example fix

// before (svelte.config.js)
const config = { kit: { adapter: adapter({ routes: { include: ['/api/*'], exclude: ['/a', '/b', '/c', /* ...95 more */] } }) } };
// after
const config = { kit: { adapter: adapter({ routes: { include: ['/api/*'], exclude: ['/*'] } }) } };
Defensive patterns

Strategy: validation

Validate before calling

const includes = routes.include ?? []; const excludes = routes.exclude ?? [];
if (includes.length + excludes.length > 100) {
  console.warn(`_routes.json rules (${includes.length + excludes.length}) exceed 100; consolidate before building`);
}

Prevention

When it happens

Trigger: Running `adapter-cloudflare`'s adapt() on a project whose generated include + exclude rule count exceeds 100 after deduplication in get_routes_json (called by adapt and routes).

Common situations: Large apps with many prerendered routes mixed with dynamic routes producing many exclude patterns; apps with broad include rules like /* plus lots of static asset excludes; misconfigured `routes`/`exclude` adapter options generating redundant rules.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/87d12fb7adf711c6. Report an issue: GitHub.