sonandmjy
sonandmjy•3w ago

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);
}
}
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
Realtime overview - Trigger.dev
Using the Trigger.dev v3 realtime API
3 Replies
Convex Bot
Convex Bot•3w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
lee
lee•3w ago
As long as it uses fetch or you have "use node", i think this would work. Two caveats: actions have a 10 minute timeout https://docs.convex.dev/production/state/limits#execution-time-and-scheduling , and every second waiting counts towards Action Compute pricing https://www.convex.dev/pricing This doesn't sound like a cheap or efficient method. If you could get Trigger.dev to send a webhook to a convex action, that sounds better. Or you could consider doing all of the stuff in Convex 🙂
Convex
Plans and Pricing
Choose the plan that works best for you and your team.
Limits | Convex Developer Hub
We’d love for you to have unlimited joy building on Convex but engineering
sonandmjy
sonandmjyOP•3w ago
ah that's what I thought, some of the things I want to do are heavy compute like video/image processing so i thought it might be better to do outside convex and send the result back thanks for the clarification @Lee first time seeing a pattern like this so was wondering if it was something I was unaware about

Did you find this page helpful?