Skip to content

fix(webapp): guard Stripe init against empty publishable key - #6985

Open
Nishal77 wants to merge 1 commit into
NangoHQ:masterfrom
Nishal77:fix/stripe-empty-key-crash
Open

fix(webapp): guard Stripe init against empty publishable key#6985
Nishal77 wants to merge 1 commit into
NangoHQ:masterfrom
Nishal77:fix/stripe-empty-key-crash

Conversation

@Nishal77

@Nishal77 Nishal77 commented Jul 31, 2026

Copy link
Copy Markdown

loadStripe() was called unconditionally with globalEnv.publicStripeKey, which is an empty string on self-hosted/local instances with no Stripe key configured. Stripe.js throws for an empty string instead of resolving null, causing an uncaught promise rejection on every page load - including pre-auth pages like /signin - plus real network beacons fired to stripe.com before any login.

Guard the call so stripePromise resolves to null when unconfigured. Downstream consumers already handle this: Plans.tsx has an existing if (!stripe) guard, and Stripe's accepts a null-resolving promise by design.

Related to #5640, which reported this exact crash for self-hosted instances. That issue and its fix (#5641) were auto-closed by the stale bot without maintainer review - confirmed the bug is still live on current master.

Closes #5640

  • Set publicStripeKey to an empty string (default on self-hosted/local dev)
  • Load /signin or /signup before this fix: uncaught IntegrationError in console + real network calls to stripe.com, before any login
  • After this fix: page loads clean, zero Stripe-related console errors, zero stripe.com network calls
  • Typecheck clean, vitest run --dir=packages/webapp passes (240/240)

cc @macko911 for review, you've touched this file/area most recently, tagging in case you have context on why the empty-key guard was never added.

Review in cubic

loadStripe() was called unconditionally with globalEnv.publicStripeKey,
which is an empty string on self-hosted/local instances with no Stripe
key configured. Stripe.js throws for an empty string instead of
resolving null, causing an uncaught promise rejection on every page
load - including pre-auth pages like /signin - plus real network
beacons fired to stripe.com before any login.

Guard the call so stripePromise resolves to null when unconfigured.
Downstream consumers already handle this: Plans.tsx has an existing
`if (!stripe)` guard, and Stripe's <Elements> accepts a null-resolving
promise by design.
@superagent-security

Copy link
Copy Markdown

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

publicStripeKey: "" crash in env.js for self-hosted instances.

1 participant