iterate.com / kernel

git clone https://git.iterate.com/repos/kernel

deploy: a product is read again right before its subscription, so none is made twice

The approval at Cloudflare takes a while. A product that came on in that time
is not subscribed to again.

Card: tasks/offer-workers-paid-and-r2-activation-in-the-deploy-cli.md
Via: /agents/claude/installer-cloudflare-card-prompt-mwynk7y7-d3de92
Session: claude 3eb581c8-1b51-4686-8d1d-b642d0822a42 on beelink
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014UJeUkb5YT4HuZzZEVabHj

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.`,