Summary
After #4831 fixed Stripe SDK method dispatch, calling a Stripe SDK method (e.g. stripe.products.create({ name })) now reaches the request layer but throws TypeError: replace is not a function — even for a flat request body. So Stripe requests still fail end-to-end on Perry.
Repro (verified on Linux; makes a real Stripe test-mode call)
import Stripe from "stripe";
const s = new Stripe(process.env.STRIPE_SECRET_KEY as string, {});
try {
const p = await s.products.create({ name: "Perry Repro DELETE" });
console.log("OK product id:", p.id);
} catch (e: any) {
console.log("ERR:", e?.name, e?.message);
console.log("STACK:", e?.stack);
}
STRIPE_SECRET_KEY=sk_test_... perry compile striperepro.ts -o striperepro && ./striperepro
Actual (bug)
ERR: TypeError replace is not a function
STACK: TypeError: replace is not a function
at <anonymous>
(e.stack collapses to at <anonymous> — see note below; a real JS stack would help a lot here.)
Localization done so far
Stripe (cjs build) has exactly 5 .replace( sites; I instrumented the three that a flat products.create would hit and none of them executed before the throw:
StripeResource.js _joinUrlParts — parts.join('/').replace(...) (path build) — never logged
utils.js queryStringifyRequestData — qs.stringify(data,...).replace(...) (body encode) — never logged
utils.js makeURLInterpolator — str.replace(...) (path interpolation) — never logged
So the failing .replace is upstream of path-building and body-encoding — i.e. in the request dispatch (stripeMethod → makeRequest → _request), header/User-Agent setup, or a transitive dependency reached before those. The receiver is a non-string value whose .replace is undefined (a TypeError: ... is not a function, not Cannot read properties of undefined).
This may share a root cause with #4831 (cross-module extend dispatch) — the dispatched method may receive an argument/this of the wrong type, so a value the SDK expects to be a string is something else.
Secondary (separate, filed as #4840)
qs.stringify on nested bodies throws Constructor WeakMap requires 'new' — will block subscription/checkout calls (nested items/line_items) once this replace issue is resolved.
Ask
A readable JS stack for uncaught TypeErrors in compiled binaries would make this trivial to localize (currently Error.stack is just at <anonymous>). Otherwise, reproducing the stripeMethod/extend request path with a flat body should surface it.
Environment
Summary
After #4831 fixed Stripe SDK method dispatch, calling a Stripe SDK method (e.g.
stripe.products.create({ name })) now reaches the request layer but throwsTypeError: replace is not a function— even for a flat request body. So Stripe requests still fail end-to-end on Perry.Repro (verified on Linux; makes a real Stripe test-mode call)
Actual (bug)
(
e.stackcollapses toat <anonymous>— see note below; a real JS stack would help a lot here.)Localization done so far
Stripe (cjs build) has exactly 5
.replace(sites; I instrumented the three that a flatproducts.createwould hit and none of them executed before the throw:StripeResource.js_joinUrlParts—parts.join('/').replace(...)(path build) — never loggedutils.jsqueryStringifyRequestData—qs.stringify(data,...).replace(...)(body encode) — never loggedutils.jsmakeURLInterpolator—str.replace(...)(path interpolation) — never loggedSo the failing
.replaceis upstream of path-building and body-encoding — i.e. in the request dispatch (stripeMethod→makeRequest→_request), header/User-Agent setup, or a transitive dependency reached before those. The receiver is a non-string value whose.replaceisundefined(aTypeError: ... is not a function, notCannot read properties of undefined).This may share a root cause with #4831 (cross-module
extenddispatch) — the dispatched method may receive an argument/thisof the wrong type, so a value the SDK expects to be a string is something else.Secondary (separate, filed as #4840)
qs.stringifyon nested bodies throwsConstructor WeakMap requires 'new'— will block subscription/checkout calls (nesteditems/line_items) once thisreplaceissue is resolved.Ask
A readable JS stack for uncaught
TypeErrors in compiled binaries would make this trivial to localize (currentlyError.stackis justat <anonymous>). Otherwise, reproducing thestripeMethod/extendrequest path with a flat body should surface it.Environment
827bfd50c(includes Stripe Node SDK: all resource methods undefined (stripe.products.create etc. is not a function) #4831)