AFU
AFU
CCConvex Community
Created by AFU on 4/10/2025 in #support-community
How can I get return value from "use node" action inside mutation ?
How can I get return value from "use node" action inside mutation ? - I try thisctx.runAction but got error "runAction does not exist", - So I move to ctx.scheduler but can not get response from that // hashActions.ts
"use node"

import bcrypt from 'bcryptjs'
import { action } from './_generated/server'
import { v } from 'convex/values'

export const hashPassword = action({
args: { password: v.string() },
handler: (ctx, args) => {
const hashedPassword = bcrypt.hashSync(args.password, "$2a$10$eImiTXuWVxfM37uY4JANjQ")
console.log('hashedPassword:', hashedPassword)
return hashedPassword
}
})
"use node"

import bcrypt from 'bcryptjs'
import { action } from './_generated/server'
import { v } from 'convex/values'

export const hashPassword = action({
args: { password: v.string() },
handler: (ctx, args) => {
const hashedPassword = bcrypt.hashSync(args.password, "$2a$10$eImiTXuWVxfM37uY4JANjQ")
console.log('hashedPassword:', hashedPassword)
return hashedPassword
}
})
// userAuths.tsx
export const signUpEmail = mutation({
args: {
email: v.string(),
password: v.string(),
},
handler: async (ctx, args) => {
const passwordHash = await ctx.scheduler.runAfter(
0,
api.hashActions.hashPassword,
{ password: args.password },
)
/** SEEM THIS return scheduler id or something but not what I expect */
console.log('passwordHash:', passwordHash)
},
})
export const signUpEmail = mutation({
args: {
email: v.string(),
password: v.string(),
},
handler: async (ctx, args) => {
const passwordHash = await ctx.scheduler.runAfter(
0,
api.hashActions.hashPassword,
{ password: args.password },
)
/** SEEM THIS return scheduler id or something but not what I expect */
console.log('passwordHash:', passwordHash)
},
})
Thank you
5 replies