Skip to content

Commit 0c04c17

Browse files
authored
fix(docs): sentry errors do not get sent from vercel edge (supabase#36377)
Sentry errors captured on routes run on Edge are not getting properly sent. This is apparently a known issue where Vercel closes the process before Sentry can flush, so the exceptions need to be manually flushed: getsentry/sentry-javascript#9626
1 parent c179175 commit 0c04c17

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

apps/docs/app/api/graphql/route.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,30 @@ function validateGraphQLRequest(query: string, isDevGraphiQL = false): ReadonlyA
114114

115115
export async function POST(request: Request): Promise<NextResponse> {
116116
try {
117-
return await handleGraphQLRequest(request)
117+
const result = await handleGraphQLRequest(request)
118+
// Do not let Vercel close the process until Sentry has flushed
119+
// https://github.com/getsentry/sentry-javascript/issues/9626
120+
await Sentry.flush(2000)
121+
return result
118122
} catch (error: unknown) {
119123
console.error(error)
120124

121125
if (error instanceof ApiError) {
122126
if (!error.isUserError()) {
123127
Sentry.captureException(error)
124128
}
129+
// Do not let Vercel close the process until Sentry has flushed
130+
// https://github.com/getsentry/sentry-javascript/issues/9626
131+
await Sentry.flush(2000)
125132

126133
return NextResponse.json({
127134
errors: [{ message: error.isPrivate() ? 'Internal Server Error' : error.message }],
128135
})
129136
} else {
130137
Sentry.captureException(error)
138+
// Do not let Vercel close the process until Sentry has flushed
139+
// https://github.com/getsentry/sentry-javascript/issues/9626
140+
await Sentry.flush(2000)
131141

132142
return NextResponse.json({
133143
errors: [{ message: 'Internal Server Error' }],

0 commit comments

Comments
 (0)