deploy: a product is read again right before its subscription, so none is made twice
Jonas Templestein, 2026-11-27 09:25 UTC · 8fbb2d2dba147fc22b2b1755415e66b92154b853 · parent 54f58aa
1 file changed
M core/lib/src/cli/deploy.ts
@@ -3144,17 +3144,23 @@ }, async (token) => { const outcomes: [Product, ReturnType<typeof activationOutcomeOf>][] = []; - for (const each of agreed) + for (const each of agreed) { + // read again first: the approval took a while, and a product that came on in that + // time (the person's own purchase, another run) is never subscribed to twice + const now = await product(each, each === "R2" ? r2Path : paidPath); outcomes.push([ each, - activationOutcomeOf( - await cloudflare(token)( - "POST", - `/accounts/${account.id}/subscriptions`, - subscriptionBodyOf(PRODUCTS[each].plan), - ), - ), + now.on + ? { on: true } + : activationOutcomeOf( + await cloudflare(token)( + "POST", + `/accounts/${account.id}/subscriptions`, + subscriptionBodyOf(PRODUCTS[each].plan), + ), + ), ]); + } return outcomes; }, ).catch((error: unknown) => (error instanceof Error ? error.message : String(error))); @@ -3168,7 +3174,7 @@ for (const [each, outcome] of made.done) { if (outcome.on) { turnedOn.add(each); - p.log.success(`Cloudflare made the subscription: ${each}.`); + p.log.success(`${each} is on.`); } else p.log.warn( `Cloudflare did not turn ${each} on (${outcome.why}). Turn it on yourself on Cloudflare's page.`,