Skip to content

SubtleCryptoProvider cannot be used in a synchronous context #1137

@lapwat

Description

@lapwat

Having this error when receiving a webhook:

CryptoProviderOnlySupportsAsyncError: SubtleCryptoProvider cannot be used in a synchronous context.
Use `await constructEventAsync(...)` instead of `constructEvent(...)`
at computeHMACSignature (/app/node_modules/stripe/cjs/crypto/SubtleCryptoProvider.js:20:39)
at verifyHeader (/app/node_modules/stripe/cjs/Webhooks.js:69:54)
at constructEvent (/app/node_modules/stripe/cjs/Webhooks.js:15:32)
at handleWebhook (/app/node_modules/@golevelup/nestjs-stripe/lib/stripe.webhook.controller.js:37:49)
at processTicksAndRejections (native:7:39)

Context

It happens in the bun 1.3.9 runtime in production.

It does not happen in the node 25 runtime.

{
    "@golevelup/nestjs-stripe": "1.2.0",
    "stripe": "20.3.1",
}

Metadata

Metadata

Labels

Pending ReproA repro is pending in order to replicate the issue

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions