Skip to content

Commit 13330a7

Browse files
committed
debug(og): surface render error message in 500 response
Temporary diagnostic — without Netlify function log access we can't see why takumi still fails on the deploy preview after the external_node_modules fix. Bake the error name/message/stack/cause into the 500 body so a `curl` against /api/og/<lib>.png shows the underlying failure (likely the napi binding load, but want to confirm before iterating). To be reverted once the binding loads cleanly.
1 parent fe3da62 commit 13330a7

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/routes/api/og/$library[.png].ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,24 @@ export const Route = createFileRoute('/api/og/$library.png')({
4646
await result.ready
4747
} catch (error) {
4848
console.error('Failed to generate OG image', error)
49-
return new Response('Failed to generate OG image', { status: 500 })
49+
// Surface the underlying message+stack in the response body so we
50+
// can diagnose Netlify-only render failures without log access.
51+
// TODO: trim back to "Failed to generate OG image" once the takumi
52+
// binding load on Netlify is verified working.
53+
const detail =
54+
error instanceof Error
55+
? `${error.name}: ${error.message}\n${error.stack ?? ''}\n${
56+
error.cause instanceof Error
57+
? `caused by ${error.cause.name}: ${error.cause.message}\n${error.cause.stack ?? ''}`
58+
: error.cause
59+
? `caused by ${String(error.cause)}`
60+
: ''
61+
}`
62+
: String(error)
63+
return new Response(`Failed to generate OG image\n\n${detail}`, {
64+
status: 500,
65+
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
66+
})
5067
}
5168

5269
return result

0 commit comments

Comments
 (0)