-
Notifications
You must be signed in to change notification settings - Fork 58
nice error on nested triggers #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd be less aggressive on the regex because I find it annoying to have to update the test whenever the error message changes. Maybe just checking the first sentence + checking a link to docs shows up in there somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could merit a specific example of what this looks like, maybe just in the triggers docs? And we could link to it from the error message?
Like
Troubleshooting: Triggers.wrapDB called multiple times in a single mutation
This usually happens if a mutation is directly calling another mutation, for instance:
export const joinTeam = mutation(...)
export const createTeam = mutation({
handler: (ctx) => {
const currentUserId = // load from auth
const team = await ctx.db.insert("teams", { creatorId: currentUserId, ... })
// ❌ This creates a new `Triggers` since it's calling another mutation
await joinTeam({ teamId })
}
})
See for the recommended pattern.
849401f to
79501fe
Compare
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.