From 7cc64d3bd174c00ca61cf1f746a48bf22bcaff54 Mon Sep 17 00:00:00 2001 From: Charis <26616127+charislam@users.noreply.github.com> Date: Thu, 19 Jun 2025 14:14:29 -0400 Subject: [PATCH] docs(edge functions): document that sentry needs to be manually flushed before main function returns (#36537) docs(edge functions): document that sentry needs to be manually flushed before main function returns Resolves #36489 --- .../guides/functions/examples/sentry-monitoring.mdx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/docs/content/guides/functions/examples/sentry-monitoring.mdx b/apps/docs/content/guides/functions/examples/sentry-monitoring.mdx index 5547de7496c..13dac78103f 100644 --- a/apps/docs/content/guides/functions/examples/sentry-monitoring.mdx +++ b/apps/docs/content/guides/functions/examples/sentry-monitoring.mdx @@ -50,6 +50,8 @@ Deno.serve(async (req) => { return new Response(JSON.stringify(data), { headers: { 'Content-Type': 'application/json' } }) } catch (e) { Sentry.captureException(e) + // Flush Sentry before the running process closes + await Sentry.flush(2000) return new Response(JSON.stringify({ msg: 'error' }), { status: 500, headers: { 'Content-Type': 'application/json' }, @@ -81,9 +83,4 @@ Find the complete example on [GitHub](https://github.com/supabase/supabase/tree/ ## Working with scopes -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. +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.