AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Custom HtmlLimitedBots UA Not In Built-In HTML_LIMITED_BOT_UA_RE Breaks PPR Resume And Drops All Page Metadata

When a request with a User-Agent matching a custom htmlLimitedBots regex but not the built-in HTML_LIMITED_BOT_UA_RE hits a non-prerendered PPR route, the server logs 'Expected the resume to render <div> in this slot but instead it rendered <__next_metadata_boundary__>', falls back to client rendering, and returns HTML with no metadata at all (no title, description, canonical). This causes severe SEO visibility loss for html-limited bots that do not execute JavaScript.

highConfidence 90%Next.jsAffected V16.2.10Affected V16.2.6

Origin Analysis

The PPR resume / metadata pipeline decides whether to render metadata blocking into <head> using the built-in HTML_LIMITED_BOT_UA_RE constant directly, while the initial shell rendering honors the user-configured htmlLimitedBots regex. This disagreement creates a mismatch between the expected resume slot and the actual metadata boundary, leading to the resume error and omitted metadata.
1. Create a Next.js 16.2.10 app with `cacheComponents: true` and `htmlLimitedBots: /GoogleOther|MySpecialBot|Twitterbot/i` in next.config.mjs.\n2. Build and start the app: `npm run build && PORT=3622 npm start`.\n3. Request a non-prerendered PPR page with a UA matching the custom regex but not the built-in list, e.g.: `curl -s -A 'MySpecialBot/1.0' http://localhost:3622/en/items/a`.\n4. Observe server log error and that `grep -c '<title>'` returns 0.\n5. Control: request with `Twitterbot/1.0` (matches both custom and built-in) returns 1 title.

Fixing Code Block

Edge Case Audit

This patch changes bot detection globally, which may expand html-limited bot rendering to additional UAs and alter caching and streaming behavior. If `htmlLimitedBots` is configured with a broad regex (e.g., /bot|crawler/), many requests may be treated as html-limited, increasing server rendering cost and potentially disabling streaming for those clients. Rollback by reverting the patch or setting `htmlLimitedBots` to false. Test with built-in bots, custom bots, regular browsers, and concurrent PPR requests. Ensure all call sites are updated; any remaining direct use of `HTML_LIMITED_BOT_UA_RE` will reintroduce the mismatch. Node.js RegExp with global/sticky flags is unsafe for repeated `test()`; this patch strips to only `i`.

Ecosystem Topology