Skip to content

Sentry Deno - supabase edge function not picking up errors #15229

@aaa3334

Description

@aaa3334

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/deno

SDK Version

import * as Sentry from "npm:@sentry/deno";

Framework Version

Deno with Supabase

Link to Sentry event

No response

Reproduction Example/SDK Setup

import * as Sentry from "npm:@sentry/deno";

Sentry.init({
  // https://docs.sentry.io/product/sentry-basics/concepts/dsn-explainer/#where-to-find-your-dsn
  dsn: Deno.env.get("SENTRY_DSN"),
  // defaultIntegrations: false,
  // Performance Monitoring
  tracesSampleRate: 1.0,
  // debug: true,
});


Sentry.setTag("region", Deno.env.get("SB_REGION"));
Sentry.setTag("execution_id", Deno.env.get("SB_EXECUTION_ID"));
Sentry.captureMessage("Hello, world!");


const handler = async (_request: Request): Promise<Response> => {
.....

  Sentry.captureException(new Error("Good bye")); -- This works

try{
...
  setTimeout(() => {
      throw new Error();
    }); -- This comes up with an error on supabase edge function but nothing comes up in the sentry dashboard

...

  } catch (error) {
    Sentry.captureException(error);
    console.error(error);

    return new Response(JSON.stringify(error), {
      status: 500,
      headers: {
        "Content-Type": "application/json",
      },
    });
  }
};

Steps to Reproduce

  1. Create an edge function or add into an existing
  2. Added in the Sentry code above (I originally followed the installation steps in Sentry itself and on Supabase's website but I realised its outdated as the deno.land package is depreciated. I am now using the npm install as in the code above
  3. Trigger the edge function

Note:
6. If this: setTimeout(() => { throw new Error(); }); is not in there, the messages above work and send through (like the 'Good bye' and 'Hello world'. If it is in there however, I get the logs appearing in supabase edge function until that point, then I get the error. I do not get any of the Good bye or Hellp world ones.

Expected Result

That this error would come up in sentry runtime and adding in this error (the example error) wouldn't stop any of the errors from going to sentry.

It is not however. I do see the error in the edgefunctions logs on supabase but not anywhere else.

Note I can see results from eg:
Sentry.captureException(new Error("Good bye"));
or
Sentry.captureMessage("Hello, world!");

Note this may be the expected behaviour and the setTimeout(() => { throw new Error(); }); might not be meant to throw an error picked up here - but that it is not working shows maybe it wont pick up other errors in here either....

Actual Result

Nothing comes up in Sentry.

This is the log for the error in the supabase edge function logs:

{
"event_message": "event loop error: Error: test\n at file:///Users/a/Documents/Automations/supabase-edge-functions/supabase/functions/pilot2email/index.ts:50:13\n at eventLoopTick (ext:core/01_core.js:203:13)",
"id": "33341939-735b-4c14-89ae-dc707dc284f0",
"metadata": [
{
"boot_time": null,
"cpu_time_used": null,
"deployment_id": "cmhsbvzpocwhojvycyin_ca0f2255-4455-42b7-8ca6-4c4ef8284b7f_16",
"event_type": "UncaughtException",
"execution_id": "506ce836-5122-4273-a7d7-ea1b7f34b2f3",
"function_id": "ca0f2255-4455-42b7-8ca6-4c4ef8284b7f",
"level": "error",
"memory_used": [],
"project_ref": "cmhsbvzpocwhojvycyin",
"reason": null,
"region": "ap-southeast-2",
"served_by": "supabase-edge-runtime-1.66.5 (compatible with Deno v1.45.2)",
"timestamp": "2025-01-30T04:59:09.683Z",
"version": "16"
}
],
"timestamp": 1738213153590102
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: denoIssues related to the Sentry Deno SDK

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions