I'm trying something which should be pretty trivial, setting up a basic hashing function that takes in a byteArray and spits out a hash data consistency purposes. Right now I'm using a internal Action that takes the ByteArray and uses the Node Crypto toolkit to digest a hash. This works well on smaller byteArrays but around a couple of MB in it starts failing with the following error:
"code": "[Request ID: 8cd403c86459d299] Server Error: Uncaught Error: Your request couldn't be completed. Try again later.",
"trace": "Uncaught Error: Your request couldn't be completed. Try again later.\n at async <anonymous> (../convex/http.ts:29:14)\n at async invokeFunction (../../node_modules/convex/src/server/impl/registration_impl.ts:79:11)\n at async invokeHttpAction (../../node_modules/convex/src/server/impl/registration_impl.ts:422:0)\n at async <anonymous> (../../node_modules/convex/src/server/router.ts:322:16)\n"
Here is my function. What is the advices approach? Can somebody tell me recommended route?
export const getMD5Hash = internalAction({
args: {
buffer: v.bytes(),
},
handler: async (_, { buffer }) => {
try {
const hash = crypto.createHash("md5");
const hashBuffer = Buffer.from(buffer);
hash.update(hashBuffer);
return hash.digest("hex");
} catch (error) {
console.error(error);
throw new Error("Failed to get MD5 hash");
}
},
});