sonandmjyS
Convex Community12mo ago
4 replies
sonandmjy

How would you handle third party subscriptions in convex

Hi, I am using convex and trigger to do background task processing and I am looking at trigger's realtime SDK. In some bit of code, they 'subscribe' to changes to the task run like in this example they gave. Was wondering is this safe to do in a convex action? Or would it cause the action to hang indefinitely or eat up a lot of bandwidth? Any advice is very much appreciated thank you!

link to the docs: https://trigger.dev/docs/realtime/overview

import { runs, tasks } from "@trigger.dev/sdk/v3";

// Somewhere in your backend code
async function myBackend() {
  const handle = await tasks.trigger("my-task", { some: "data" });

  for await (const run of runs.subscribeToRun(handle.id)) {
    // This will log the run every time it changes
    console.log(run);
  }
}
Trigger.dev
Using the Trigger.dev v3 realtime API
Was this page helpful?