Skip to content

Commit 7cc64d3

Browse files
authored
docs(edge functions): document that sentry needs to be manually flushed before main function returns (supabase#36537)
docs(edge functions): document that sentry needs to be manually flushed before main function returns Resolves supabase#36489
1 parent 5cc2617 commit 7cc64d3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

apps/docs/content/guides/functions/examples/sentry-monitoring.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Deno.serve(async (req) => {
5050
return new Response(JSON.stringify(data), { headers: { 'Content-Type': 'application/json' } })
5151
} catch (e) {
5252
Sentry.captureException(e)
53+
// Flush Sentry before the running process closes
54+
await Sentry.flush(2000)
5355
return new Response(JSON.stringify({ msg: 'error' }), {
5456
status: 500,
5557
headers: { 'Content-Type': 'application/json' },
@@ -81,9 +83,4 @@ Find the complete example on [GitHub](https://github.com/supabase/supabase/tree/
8183

8284
## Working with scopes
8385

84-
Sentry Deno SDK currently do not support `Deno.serve` instrumentation, which means that there is no scope separation between requests.
85-
Because of that, when the Edge Functions runtime is reused between multiple requests, all globally captured breadcrumbs and contextual data
86-
will be shared, which is not the desired behavior. To work around this, all default integrations in the example code above are disabled,
87-
and you should be relying on [`withScope`](https://docs.sentry.io/platforms/javascript/enriching-events/scopes/#using-withscope) to encapsulate
88-
all Sentry SDK API calls, or [pass context directly](https://docs.sentry.io/platforms/javascript/enriching-events/context/#passing-context-directly)
89-
to the `captureException` or `captureMessage` calls.
86+
Sentry Deno SDK currently do not support `Deno.serve` instrumentation, which means that there is no scope separation between requests. Because of that, when the Edge Functions runtime is reused between multiple requests, all globally captured breadcrumbs and contextual data will be shared, which is not the desired behavior. To work around this, all default integrations in the example code above are disabled, and you should be relying on [`withScope`](https://docs.sentry.io/platforms/javascript/enriching-events/scopes/#using-withscope) to encapsulate all Sentry SDK API calls, or [pass context directly](https://docs.sentry.io/platforms/javascript/enriching-events/context/#passing-context-directly) to the `captureException` or `captureMessage` calls.

0 commit comments

Comments
 (0)