trigger.dev icon indicating copy to clipboard operation
trigger.dev copied to clipboard

bug: SDK fails in Supabase Edge (Deno) runtime when calling task.trigger()

Open isshaddad opened this issue 9 months ago • 3 comments

Provide environment information

trigger v4.4.1 but also happens with previous versions

Describe the bug

When triggering a task from a Supabase Edge Function using tasks.trigger() (or task.trigger()), the runtime throws:

TypeError: Cannot read properties of undefined (reading 'toString') at @bugsnag/cuid (fingerprint.mjs).

This only occurs when the SDK is used to trigger; it does not occur when triggering via the REST API (POST to https://api.trigger.dev/api/v1/tasks/<taskId>/trigger).

Expected: Task triggers successfully from the Edge Function using the SDK.

Actual: Runtime error from a dependency that expects Node-style APIs not available in the Supabase Edge (Deno) runtime. Treating as environment compatibility issue; workaround is to use the Tasks API with fetch instead of the SDK (documented in the Supabase Edge Functions guide).

Reproduction repo

n/a

To reproduce

  1. Follow Triggering tasks from Supabase edge functions.
  2. In the edge function, use tasks.trigger() (or task.trigger()) with the SDK, e.g. import { tasks } from "@trigger.dev/sdk/v3".
  3. Deploy the edge function and invoke it (e.g. hit the function URL or trigger via a DB webhook).
  4. Observe runtime error: TypeError: Cannot read properties of undefined (reading 'toString') at @bugsnag/cuid fingerprint.mjs.

Workaround: trigger via the Tasks API with fetch instead of the SDK.

Additional information

No response

isshaddad avatar Feb 27 '26 15:02 isshaddad

Same goes with npm:@trigger.dev/sdk@latest/v3. No luck. Is there any mapping or different path?

muhaimincs avatar Mar 22 '26 12:03 muhaimincs

this feels less like a generic supabase edge problem and more like one dependency in the sdk path assuming node style runtime APIs. the giveaway is that tasks.trigger() fails but the raw http call works, so the failure looks like sdk-side setup rather than the trigger endpoint itself. i also noticed the earlier proposed fix was around the internal id generation path, which would fit the @bugsnag/cuid stack trace, but since that change was never really carried through i would probably confirm that exact path first before changing docs. if that is the boundary, the safest fix is to swap that dependency for an edge-safe id generator and add one runtime test for deno or supabase edge so this does not regress.

rnagulapalle avatar Apr 20 '26 01:04 rnagulapalle

The workaround works for triggers but not for real-time token generation.

a0m0rajab avatar Jul 28 '26 00:07 a0m0rajab