marnec
marnec•2mo ago

resend not working in internalMutation

I had a problem where I wasn't able to send emails with Resend. My API key was configured, my resend domain was verified and magic link email were working fine (after setting the from param). But when I tried to send emails at runtime resend.emails.send() would give the error
{
name: 'application_error',
message: 'Unable to fetch data. The request could not be resolved.'
}
{
name: 'application_error',
message: 'Unable to fetch data. The request could not be resolved.'
}
After a long time debugging I found out that my problem was that I was trying to send emails from an internalMutation. I switched to internalAction and all immediately worked. Could someone please explain the reason for this?
I also read the docs extensively but I hadn't found or anticipated that this would happen
8 Replies
Convex Bot
Convex Bot•2mo 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!
FleetAdmiralJakob 🗕 🗗 🗙
Actions have access to "the internet". So basically they can interact with things outside of Convex. While mutations and query can't.
FleetAdmiralJakob 🗕 🗗 🗙
Actions can call third party services to do things such as processing a payment with Stripe. They can be run in Convex's JavaScript environment or in Node.js. They can interact with the database indirectly by calling queries and mutations.
https://docs.convex.dev/functions/actions
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment
FleetAdmiralJakob 🗕 🗗 🗙
Mutations insert, update and remove data from the database, check authentication or perform other business logic, and optionally return a response to the client application.
https://docs.convex.dev/functions/mutation-functions
Mutations | Convex Developer Hub
Mutations insert, update and remove data from the database, check authentication
marnec
marnecOP•2mo ago
😳 thanks !! I really missed the fact the mutations cannot call 3rd party APIs.
ballingt
ballingt•2mo ago
Ah that's tough, you didn't see the error because it was a scheduled function?
ballingt
ballingt•2mo ago
When I run a mutation that fetches directly I get
No description
ballingt
ballingt•2mo ago
but since you scheduled this, you would have had to check the dashboard logs to see the error

Did you find this page helpful?