Skip to content

Fix social card images returning a 500 - #4880

Merged
marcoacierno merged 1 commit into
mainfrom
claude/practical-ptolemy-oys409
Dec 2, 2026
Merged

marcoacierno merged 1 commit into
mainfrom
claude/practical-ptolemy-oys409

Conversation

@marcoacierno

Copy link
Copy Markdown
Member

What

The social card images (/api/en/social-card and the news, keynote and event variants) returned a 500 on every request. This moves the four routes from the Edge runtime to the default Node.js runtime, which makes them render again.

Why

Next bundles the configured cacheHandler into every Edge function. cache-handler.mjs imports redis and @fortedigital/nextjs-cache-handler, which need Node built-ins, so the routes crashed while loading:

Error: Failed to load external module node:assert/strict: TypeError: Native module not found: node:assert/strict

Next 16 also deprecates the Edge runtime and asks for the runtime export to be removed.

Changes

  • Drop runtime: "edge" from the four social card routes and switch the handlers to NextApiRequest / NextApiResponse.
  • Read the fonts and the main illustration from public/ on disk instead of fetching them over HTTP from the site's own origin.
  • Share the image response code in sendSocialCard (frontend/src/helpers/social-card.tsx).

Testing

Run locally against a mock GraphQL backend built from backend/schema.graphql:

  • Before: /api/en/social-card returns the 500 above in next dev and in a production standalone build.
  • After: all four routes return a 1200×630 PNG in next dev and in a production standalone build with the Redis cache handler connected. /api/it/social-card renders the Italian month name.
  • The standalone output traces the @vercel/og wasm and font files plus the three assets read from public/.
  • The rendered card matches the old Edge render apart from anti-aliasing on shape edges.

ToDo

  • Check the cards on the deployed site with real conference data. The Docker image and the real backend were not run here.

Generated by Claude Code

The social card API routes ran on the Edge runtime, where Next bundles
the configured cacheHandler into every edge function. cache-handler.mjs
pulls in redis and @fortedigital/nextjs-cache-handler, which need Node
built-ins such as node:assert/strict, so the routes failed while loading
and every request returned a 500.

Run the routes on the default Node.js runtime, read the fonts and the
illustration from disk rather than fetching them from the site's own
origin, and share the image response code between the four routes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015yeTaRwbVxnHtah3pLH4K4
@vercel

vercel Bot commented Dec 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pycon Error Error Dec 2, 2026 10:17am UTC

Request Review

@claude

claude Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Moves the four social card API routes from the Edge runtime to Node. They now read fonts and the illustration from public/ and share the response code in sendSocialCard.

Minor points:

  • frontend/src/helpers/social-card.tsx: sendSocialCard reads both font files from disk on every request. Module-level memoisation of the font buffers would avoid the repeated I/O. This matters more now that rendering runs in the Node server process instead of the edge.
  • talk.title / talk.speakers (event and keynotes routes) still throw when the talk is missing, so an unknown slug returns a 500. This was already the case before the PR. The routes now sit behind the default Node API handler, so a 404 would be cheap to add.
  • The ToDo is still open: verify on the deployed Docker image that the public/ assets are present in the standalone output at process.cwd().

@marcoacierno
marcoacierno merged commit 664d6ce into main Dec 2, 2026
5 of 7 checks passed
@marcoacierno
marcoacierno deleted the claude/practical-ptolemy-oys409 branch December 2, 2026 16:43

This branch had an error being deployed

1 failed deployment
Preview — 3b57e078 Deployed Dec 2, 2026 by vercel[bot]
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.

2 participants