Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/docs/app/api/graphql/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,30 @@ function validateGraphQLRequest(query: string, isDevGraphiQL = false): ReadonlyA

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

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

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

return NextResponse.json({
errors: [{ message: 'Internal Server Error' }],
Expand Down
Loading
Loading