You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
plugin-ecommerce: Stripe adapter hangs on Cloudflare Workers (workerd) — new Stripe() needs a fetch httpClient #17201
With no httpClient, the Stripe Node SDK falls back to its default Node https-module (socket-based) client. That client does not work on Cloudflare Workers (workerd), where all outbound requests must go through fetch. The result: initiatePayment (and confirmOrder) hang indefinitely — no error, no timeout, the request never resolves.
The insidious part: this is invisible in local development. next dev runs on Node, where the default client works fine, so the entire checkout passes local testing. It only fails on the real Workers runtime (opennextjs-cloudflare preview or production), where checkout silently hangs.
Root cause
The Stripe Node SDK requires httpClient: Stripe.createFetchHttpClient() to run on Workers/edge runtimes. The adapter neither sets it nor exposes a way for the consumer to set it (stripeAdapter accepts secretKey / publishableKey / webhookSecret, but no httpClient or Stripe config passthrough).
Fix (verified end-to-end on workerd)
Adding the fetch HTTP client to both new Stripe() calls resolves it completely:
With this change, the full money path runs on workerd: initiatePayment → PaymentIntent + transaction, confirmOrder → order created + stock decremented. Without it, initiatePayment hangs forever.
Two possible directions:
Detect a non-Node runtime and default to createFetchHttpClient(), or
Expose an httpClient (or general Stripe config) option on stripeAdapter so consumers can inject it. This would also let people avoid patching the package to deploy on Workers.
Ruled out
Bumping compatibility_date (2025-08-15 → 2025-11-01) with nodejs_compat enabled does not fix it — it is specifically the HTTP client, not a missing Node polyfill.
The hang is real, but the missing httpClient is not the cause — the constructor is fine. stripe
already declares a workerd export condition ([email protected] package.json: "workerd": { "import": "./esm/stripe.esm.worker.js" }), which selects the fetch-based client. What
fails is the bundler: Next/Turbopack + OpenNext resolve stripe under the default condition, so
the Node build is selected and the request never leaves the Worker.
Fixed with build config only — zero plugin changes. In next.config.ts, production build only:
where the stub re-exports node_modules/stripe/esm/stripe.esm.worker.js by deep relative path.
That indirection is necessary, not stylistic: every key in the package's exports map is a condition, not a subpath, so stripe/esm/stripe.esm.worker.js is ERR_PACKAGE_PATH_NOT_EXPORTED,
and aliasing stripe to itself is a no-op.
Measured on a built OpenNext Worker (wrangler dev, local D1), POST /api/payments/stripe/initiate
with a CAD cart and a Stripe test key:
before (Node build selected): HTTP 000, curl exit 28 — it hangs. Capped at 45 s here; an earlier
run of the same request was left to run and returned nothing after 150 s, past Stripe's own timeout.
after (workerd build selected): HTTP 200 in 0.82 s, returning a real PaymentIntent, with the
matching transactions row written pending at 1999 CAD.
A bundle-level check on the built worker, if you want one that discriminates: the Node build's TLS
cipher string DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5 (unique to net/NodeHttpClient.js)
reads 4 occurrences without the alias and 0 with it, while createNodeHttpClient not implemented. stays at 4 in both, confirming stripe is bundled either way.
Worth flagging that several obvious markers do not discriminate — createNodeHttpClient, return "fetch" and secureConnect all appear in both builds, the first two because they live in the
shared abstract base class and the third because FetchHttpClient.js uses it too.
A second, separate defect surfaces once payments work: webhooks.ts uses the synchronous constructEvent, which throws SubtleCryptoProvider cannot be used in a synchronous context on
workerd, so every webhook 400s while answering {"received": true}. One-line fix, PR: #18125
Activity
LuigiNicaPRO commentedon Sep 8, 2026
The hang is real, but the missing
httpClientis not the cause — the constructor is fine.stripealready declares a
workerdexport condition ([email protected] package.json:"workerd": { "import": "./esm/stripe.esm.worker.js" }), which selects the fetch-based client. Whatfails is the bundler: Next/Turbopack + OpenNext resolve
stripeunder thedefaultcondition, sothe Node build is selected and the request never leaves the Worker.
Fixed with build config only — zero plugin changes. In
next.config.ts, production build only:where the stub re-exports
node_modules/stripe/esm/stripe.esm.worker.jsby deep relative path.That indirection is necessary, not stylistic: every key in the package's
exportsmap is acondition, not a subpath, so
stripe/esm/stripe.esm.worker.jsisERR_PACKAGE_PATH_NOT_EXPORTED,and aliasing
stripeto itself is a no-op.Measured on a built OpenNext Worker (
wrangler dev, local D1),POST /api/payments/stripe/initiatewith a CAD cart and a Stripe test key:
run of the same request was left to run and returned nothing after 150 s, past Stripe's own timeout.
matching
transactionsrow writtenpendingat 1999 CAD.A bundle-level check on the built worker, if you want one that discriminates: the Node build's TLS
cipher string
DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5(unique tonet/NodeHttpClient.js)reads 4 occurrences without the alias and 0 with it, while
createNodeHttpClient not implemented.stays at 4 in both, confirming stripe is bundled either way.Worth flagging that several obvious markers do not discriminate —
createNodeHttpClient,return "fetch"andsecureConnectall appear in both builds, the first two because they live in theshared abstract base class and the third because
FetchHttpClient.jsuses it too.A second, separate defect surfaces once payments work:
webhooks.tsuses the synchronousconstructEvent, which throwsSubtleCryptoProvider cannot be used in a synchronous contextonworkerd, so every webhook 400s while answering
{"received": true}. One-line fix, PR: #18125