mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 01:15:03 +03:00
Capture exception in edge functions body query (#43628)
## Context Trying to catch any parsing errors into sentry
This commit is contained in:
1 parent
87e3e8aa2a
commit
c0692111b7
2 files changed
+36
-19
No files matched your search
@@ -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 { getMultipartBoundary, parseMultipartStream } from '@mjackson/multipart-parser'
|
||||||
|
import * as Sentry from '@sentry/nextjs'
|
||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
|
||||||
import { FileData } from '@/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.types'
|
|
||||||
import { get, handleError } from 'data/fetchers'
|
import { get, handleError } from 'data/fetchers'
|
||||||
import { IS_PLATFORM } from 'lib/constants'
|
|
||||||
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
import type { ResponseError, UseCustomQueryOptions } from 'types'
|
||||||
|
|
||||||
import { edgeFunctionsKeys } from './keys'
|
import { edgeFunctionsKeys } from './keys'
|
||||||
|
import { FileData } from '@/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.types'
|
||||||
|
|
||||||
type EdgeFunctionBodyVariables = {
|
type EdgeFunctionBodyVariables = {
|
||||||
projectRef?: string
|
projectRef?: string
|
||||||
@@ -38,24 +38,33 @@ export async function getEdgeFunctionBody(
|
|||||||
deno2_entrypoint_path?: string | null
|
deno2_entrypoint_path?: string | null
|
||||||
} = {}
|
} = {}
|
||||||
|
|
||||||
for await (let part of parseMultipartStream(data, {
|
try {
|
||||||
boundary,
|
for await (let part of parseMultipartStream(data, {
|
||||||
maxFileSize: 20 * 1024 * 1024,
|
boundary,
|
||||||
})) {
|
maxFileSize: 20 * 1024 * 1024,
|
||||||
if (part.isFile) {
|
})) {
|
||||||
files.push({
|
if (part.isFile) {
|
||||||
name: part.filename,
|
files.push({
|
||||||
content: part.text,
|
name: part.filename,
|
||||||
})
|
content: part.text,
|
||||||
} else {
|
})
|
||||||
// treat it as metadata
|
} else {
|
||||||
metadata = JSON.parse(part.text)
|
// treat it as metadata
|
||||||
|
metadata = JSON.parse(part.text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
metadata,
|
metadata,
|
||||||
files: files as Omit<FileData, 'id' | 'selected' | 'state'>[],
|
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