Capture exception in edge functions body query (#43628)

## Context

Trying to catch any parsing errors into sentry
This commit is contained in:
Joshen Lim
2026-03-11 16:09:36 +07:00
committed by GitHub
parent 87e3e8aa2a
commit c0692111b7
2 changed files with 36 additions and 19 deletions
+8
View File
@@ -0,0 +1,8 @@
{
"mcpServers": {
"supabase": {
"type": "http",
"url": "https://mcp.supabase.com/mcp"
}
}
}
@@ -1,11 +1,11 @@
import { getMultipartBoundary, parseMultipartStream } from '@mjackson/multipart-parser'
import * as Sentry from '@sentry/nextjs'
import { useQuery } from '@tanstack/react-query'
import { FileData } from '@/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.types'
import { get, handleError } from 'data/fetchers'
import { IS_PLATFORM } from 'lib/constants'
import type { ResponseError, UseCustomQueryOptions } from 'types'
import { edgeFunctionsKeys } from './keys'
import { FileData } from '@/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.types'
type EdgeFunctionBodyVariables = {
projectRef?: string
@@ -38,24 +38,33 @@ export async function getEdgeFunctionBody(
deno2_entrypoint_path?: string | null
} = {}
for await (let part of parseMultipartStream(data, {
boundary,
maxFileSize: 20 * 1024 * 1024,
})) {
if (part.isFile) {
files.push({
name: part.filename,
content: part.text,
})
} else {
// treat it as metadata
metadata = JSON.parse(part.text)
try {
for await (let part of parseMultipartStream(data, {
boundary,
maxFileSize: 20 * 1024 * 1024,
})) {
if (part.isFile) {
files.push({
name: part.filename,
content: part.text,
})
} else {
// treat it as metadata
metadata = JSON.parse(part.text)
}
}
}
return {
metadata,
files: files as Omit<FileData, 'id' | 'selected' | 'state'>[],
return {
metadata,
files: files as Omit<FileData, 'id' | 'selected' | 'state'>[],
}
} catch (error) {
if (error instanceof Error) {
Sentry.captureException(error, {
extra: { error, data, response, boundary },
})
}
throw error
}
}