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

Next.Js Fails To Generate Static Shell When GenerateMetadata Uses Runtime Data With CacheComponents And HtmlLimitedBots Enabled

When cacheComponents is true and htmlLimitedBots matches all bots, using runtime data (e.g. await connection()) inside generateMetadata causes Next.js 16 dev server to log 'did not produce a static shell and Next.js was unable to determine a reason', disrupting development and potentially affecting build/start.

highConfidence 75%Next.jsAffected V16.0.0Affected V16.0.1Affected V16.0.2Affected V16.0.3Affected V16.0.4Affected V16.0.5

Origin Analysis

The dynamic rendering reason generated by runtime data (such as connection()) inside generateMetadata is not propagated to the static shell detection logic when cacheComponents and htmlLimitedBots are combined, causing Next.js to lose track of why the route cannot be statically shelled and thus report an internal bug.
1. Create a new Next.js 16 app with pnpm create next-app. 2. In next.config.ts set cacheComponents: true and htmlLimitedBots: /.*/. 3. In app/page.tsx add an async generateMetadata that calls await connection() (or any runtime data access) and returns metadata. 4. Run pnpm dev and open the home page. Observe repeated error logs in the terminal.

Fixing Code Block

Edge Case Audit

Forcing dynamic rendering disables static optimization for that route, which may increase server load and response times. This is a temporary workaround; once the underlying bug is fixed in a future Next.js release, remove the line and re-enable static generation if desired. Monitor performance in production and test with high concurrency to ensure acceptable overhead. Rollback is straightforward by deleting the added export.

Ecosystem Topology