Skip to content

fix: skip runtime buffer cache during prerender (#613)#626

Merged
harlan-zw merged 1 commit into
mainfrom
fix/613-skip-cache-prerender
Jun 5, 2026
Merged

fix: skip runtime buffer cache during prerender (#613)#626
harlan-zw merged 1 commit into
mainfrom
fix/613-skip-cache-prerender

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Follow-up to #619 / #613.

❓ Type of change

  • 🐞 Bug fix

📚 Description

#619 made the cache degrade gracefully when the backend is unreachable, which stops the build from failing. This is the cleaner companion fix: don't use the runtime buffer cache during prerender at all.

The Invalid binding KV: undefined in #613 fires during prerender because the buffer cache reaches for the configured backend, but a Cloudflare KV binding only exists at runtime in the Worker, not in the Node build environment doing the prerender. Beyond Cloudflare, this is correct for every preset: prerendered images are written to static files served by the /_og/s/** route rule (immutable, max-age=1yr), so the runtime buffer cache is irrelevant to serving them.

  • Exclude import.meta.prerender from intentionallyEnabled, so prerender never touches the runtime cache backend.
  • Skip the no-store header block during prerender, so the static output keeps the route rule's long-cache policy instead of being marked uncacheable.

This got left out of #619 when it merged (PR head-ref lag merged the prior commit), hence the standalone PR. With this, the reporter's runtimeCacheStorage: false workaround is no longer needed.

The root trigger for #613: during prerender the buffer cache reaches for the
configured backend, but a Cloudflare KV binding only exists at runtime in the
Worker, not in the Node build environment — hence `Invalid binding KV: undefined`.
The graceful degradation added here catches that, but prerender shouldn't touch
the runtime cache at all: prerendered images are written to static files served
via the `/_og/s/**` route rule, which already sets immutable caching.

Disable the buffer cache when `import.meta.prerender` is set, and skip the
no-store headers in that case so the static output keeps the route rule's
caching policy instead of being marked uncacheable.
@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nuxt-og-image@626

commit: 6573beb

@harlan-zw harlan-zw merged commit f5ae450 into main Jun 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant