mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 08:56:46 -04:00
Capture exception in edge functions body query (#43628)
## Context Trying to catch any parsing errors into sentry
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user