#kevalmandalik

1 messages · Page 1 of 1 (latest)

wide fractalBOT
#

Hello kevalmandalik, we'll be with you shortly! Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
kevalmandalik, 5 days ago, 8 messages
kevalmandalik, 6 days ago, 26 messages
kevalmandalik, 6 days ago, 9 messages

minor crater
#

hello! can you share the full stacktrace and which line of code specifically is resulting in this error?

urban spear
#

yeah sure

#

@minor crater here's my frontend code

#

in frontend i am using reactjs with type script and in backend i am using wrangler

#

exact line which is causing error is one in try block

#

@minor crater

#

this error i am receiving

#

@minor crater

minor crater
#

I'm juggling a number of questions at the moment, so it may take a while longer for me to look into this. Sorry about the wait

winged salmon
#

Hi @urban spear did you use SubtleCryptoProvider anywhere in your code?

urban spear
#

no i haven't used in my code may be it is using from internal library

#

i am blocked due to this for 5 long day and my project delivery also get delayed so can you plz help me

winged salmon
urban spear
#

i am using this one

stripe

#

not stripe-node

winged salmon
#

Can you check your package.json file and confirm if you are not using stripe-node, or any pacakge that have dependency on stripe-node?

urban spear
#

here's list of dependency i am using

winged salmon
#

You are using stripe-node. see the second last dependency

#

I'd suggest you to check your usage of stripe-node SDK, and see which one could trigger SubtleCryptoProvider

urban spear
#

should i install crypto npm package?

#

@winged salmon i found out stripe.webhooks.signature.verifyHeader(payload, signature, appSecret);

in above line is goes to

winged salmon
#

Ok, how did you impememnt the webhook verification?

urban spear
#

try{
await stripe.webhooks.signature.verifyHeader(payload, signature, appSecret);
}catch(e:any){
console.log(e);
return new Response(${JSON.stringify({ "message": e.message, "success": false })}, {
status: 400, headers: {
"content-type": "application/json",
"Access-Control-Allow-Origin": "*"
}
});
}

this way

winged salmon
#

Is this part of code running in a synchronous context?

urban spear
#

i have used async await how it can we synchronous

winged salmon
#

remove the await

urban spear
#

Error: SubtleCryptoProvider cannot be used in a synchronous context.
at SubtleCryptoProvider.computeHMACSignature (worker.js:2062:15)
at Object.verifyHeader (worker.js:8903:52)
at worker.js:10358:37
at async Object.handle (worker.js:9375:29)
at async jsonError (worker.js:11559:12) {
stack: Error: SubtleCryptoProvider cannot be used in a sy…5:29)
at async jsonError (worker.js:11559:12),
message: SubtleCryptoProvider cannot be used in a synchronous context.
}
[mf:inf] POST /api/v1/salesforce/submission-list 400 Bad Request (3190ms)
this is recent most error i got in console

winged salmon
#

Have you removed the await?

urban spear
#

yeah ofcourse

winged salmon
#

I saw a async jsonError, can you check again and make sure the worker.js is not in synchronous context?

urban spear
#

you can check here code snippet of worker js

winged salmon
#

There's still a async, isn't it?

urban spear
#

actual error is SubtleCryptoProvider cannot be used in a synchronous context

so i have to use async/await to make asynchronous manner

winged salmon
#

I don't think that's the right way to interpret the message. My understand is that you need to use in async context, and using await will make the execution synchrnous.

urban spear
#

@winged salmon i found out something wrong in method implementation

kindly confirm verifyHeader every time calling computeHMACSignature(payload, signature) method and in implementation it's only throwing error

wide fractalBOT
urban spear
#

@obsidian mesa is this right way to implement method

winged salmon
#

@urban spear that's intentional as it's not supposed to run synchronously.