fix(metadata): accept a single openGraph video or audio entry like Next.js by RaphaelFakhri · Pull Request #4143 · cloudflare/vinext · GitHub
Skip to content

fix(metadata): accept a single openGraph video or audio entry like Next.js - #4143

Merged
james-elicx merged 4 commits into
cloudflare:mainfrom
RaphaelFakhri:fix/metadata-og-video-audio-single
Oct 22, 2026
Merged

james-elicx merged 4 commits into
cloudflare:mainfrom
RaphaelFakhri:fix/metadata-og-video-audio-single

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

MetadataHead iterates openGraph.videos and openGraph.audio as arrays of descriptors. Next.js types both fields as OGVideo | Array<OGVideo> and OGAudio | Array<OGAudio>, where each entry is a URL string, a URL, or a descriptor. As a result:

  • A single descriptor such as videos: { url: "https://example.com/v.mp4" } throws TypeError: og.videos is not iterable, so the page fails to render.
  • A single URL string such as audio: "https://example.com/a.mp3" iterates the string's characters and emits one empty og:audio tag per character.
  • URL-only array entries emit og:video / og:audio tags without content.
  • secureUrl and type are dropped, so og:video:secure_url, og:video:type, og:audio:secure_url and og:audio:type never render.
  • Relative video and audio URLs are resolved against metadataBase. Next.js renders them as written (String(url)); only images go through metadataBase.

This change normalizes both fields with the existing normalizeUrlDescriptorEntries helper (already used for icons), renders the URLs as written, and emits secure_url and type in the same order as Next.js's metadata.tsx. Descriptors without a url skip the og:video / og:audio tag, as in Next.js.

Expected output was captured from a real next@16.2.7 build serving the same metadata: videos: { url: "/v.mp4", ... } with metadataBase: new URL("https://base.example.com") renders og:video as /v.mp4, and URL entries render their href.

Test plan

  • New fixture pages tests/fixtures/app-basic/app/nextjs-compat/metadata-opengraph-video-audio (single descriptor + single string) and .../list (strings, URLs and descriptors), both with a metadataBase.
  • Two dev-server integration tests in tests/nextjs-compat/metadata.test.ts assert the exact ordered og:video* / og:audio* tags Next.js renders.
  • Both fail on main (og.videos is not iterable) and on the earlier revision of this PR (URLs absolutized against metadataBase); both pass now.
  • vp check passes.

Fixes #4142

@clanky-the-clanker

Copy link
Copy Markdown

Next.js renders og:video and og:audio URLs verbatim instead of resolving
them against metadataBase. Cover single entries, lists, URL objects and
descriptor fields with fixture pages in the Next.js compat metadata suite.
@james-elicx

Copy link
Copy Markdown
Member

/bigbonk review for issues
Please review exact head 55c62002dc5c534b19f4a45a17e8a70e0a7e716e without modifying or pushing the branch. Report all actionable findings within your 8-minute time limit.

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/@vinext/cloudflare@4143

create-vinext-app

npm i https://pkg.pr.new/create-vinext-app@4143

@vinext/types

npm i https://pkg.pr.new/@vinext/types@4143

vinext

npm i https://pkg.pr.new/vinext@4143

@cloudflare/workers-response-store

npm i https://pkg.pr.new/@cloudflare/workers-response-store@4143

commit: 55c6200

@ask-bonk

ask-bonk Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@github-actions

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 55c6200 against base 466e278 using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 7 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 151.4 KB 151.4 KB ⚫ -0.0%
Client entry size (gzip) vinext 140.9 KB 140.9 KB ⚫ -0.0%
Dev server cold start vinext 2.82 s 2.80 s ⚫ -0.4%
Dev server cold start (large Pages Router app) vinext 23.57 s 23.49 s ⚫ -0.3%
Production build time vinext 3.35 s 3.40 s ⚫ +1.3%
RSC entry closure size (gzip) vinext 143.9 KB 144.0 KB ⚫ +0.1%
Server bundle size (gzip) vinext 249.6 KB 249.7 KB ⚫ +0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@james-elicx
james-elicx merged commit 5c9fbce into cloudflare:main Oct 22, 2026
87 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.

Metadata: a single openGraph video or audio entry crashes the page or renders empty tags

2 participants