Need help with action retrier
I’ve got the suggestion from Jamie to use Action retrier, but I want to trigger it from next js server actions, could not find any documentation for that, so reaching out here,
I am unable to pass the token of clerk to it so that it can property authenticate and run these actions, where can i get the help from:
3 Replies
Retrier is using scheduling to retry the action, and scheduled functions don't have access to auth info - you'll need to pass the auth info into the function.
Looking at the repo, though, I'm honestly not sure how auth is expected to be used here since the retrier is being invoked from the client. I'm going to noodle on that a bit.
I believe your best bet here is to use retrier on scheduled actions. So, for any authenticated action that you want to retry, call another action that does the auth check, and then passes the authenticated user info (not the token) to a scheduled function that uses retrier, eg.,
cc/ @james in case I'm missing something and there's a better way with this lib
I would restructure the code to not call the action retrier directly. You probably want a different function that handles the request from next, checks auth and then calls the action retrier with the relevant action.
That's what I'm recommending as well, but you said it much more clearly lol
Ah but no need to schedule, I see that now - you can just call the action via
ctx.runAction()