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} contentView on GitHub (pinned to 03f1687fe6)
Solutions
- Reduce the number of routes or broaden include/exclude patterns so the total stays under 100.
- Prerender more routes so they are excluded by fewer, broader patterns instead of many specific ones.
- Consolidate static assets into fewer directories and exclude those directories wholesale.
- 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
- Count include+exclude rules in CI and fail the build above ~90 rules
- Prefer broad glob excludes over many specific paths
- Prerender routes so broad excludes cover them
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
- No netlify.toml found. Using default publish directory. Cons
- Detected ${platform.name}. Please remove adapter-static opti
- Warning: The following routes have an ISR config which is i
- Warning: The following modules failed to locate dependencies
- Warning: vercel.json defines cron tasks that use paths that
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/87d12fb7adf711c6.
Report an issue: GitHub.