From 22da68a5f5646123c926d9d3d3777f21993462f8 Mon Sep 17 00:00:00 2001 From: mdong Date: Tue, 1 Dec 2026 08:44:05 +0800 Subject: [PATCH 1/2] fix(platform): error early when wfp is not enabled during install --- packages/void/src/cli/platform-lifecycle.ts | 11 +++++++ .../unit/platform-install-prompts.test.ts | 1 + .../test/unit/platform-setup-flow.test.ts | 33 +++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/packages/void/src/cli/platform-lifecycle.ts b/packages/void/src/cli/platform-lifecycle.ts index 9ea553695..81d071289 100644 --- a/packages/void/src/cli/platform-lifecycle.ts +++ b/packages/void/src/cli/platform-lifecycle.ts @@ -32,6 +32,7 @@ import { PlatformCloudflareApiError, PlatformRuntimeTokenEmailPermissionError, verifyPlatformRuntimeTokenPermissions, + PlatformCloudflarePrerequisiteError, } from './platform-cloudflare.ts'; import type { CloudflareAccount } from './platform-cloudflare.ts'; import { platformCredentialHelp } from './platform-credential-label.ts'; @@ -392,6 +393,16 @@ export async function runPlatformLifecycleCommand(commandArgs: PlatformArgs): Pr ) { throw new Error('platform: The installation belongs to a different Cloudflare account.'); } + // Fail before the domain questions when Workers for Platforms is off. Planning + // repeats this read and reports permission denials together, so only the + // missing-product error stops here. + try { + await client.listDispatchNamespaces(accountId); + } catch (error) { + if (error instanceof PlatformCloudflarePrerequisiteError) { + throw error; + } + } const recorded = existing?.deployment; if ( existing && diff --git a/packages/void/test/unit/platform-install-prompts.test.ts b/packages/void/test/unit/platform-install-prompts.test.ts index 063f2377a..c61f9b07c 100644 --- a/packages/void/test/unit/platform-install-prompts.test.ts +++ b/packages/void/test/unit/platform-install-prompts.test.ts @@ -90,6 +90,7 @@ beforeEach(() => { { id: 'account', name: 'Account' }, ]); vi.spyOn(PlatformCloudflareClient.prototype, 'listHyperdriveConfigs').mockResolvedValue([]); + vi.spyOn(PlatformCloudflareClient.prototype, 'listDispatchNamespaces').mockResolvedValue([]); mocks.text.mockImplementation(async ({ defaultValue }) => defaultValue ?? ''); mocks.select.mockImplementation(async ({ message, options }) => message === 'How should Void set up Hyperdrive?' || diff --git a/packages/void/test/unit/platform-setup-flow.test.ts b/packages/void/test/unit/platform-setup-flow.test.ts index e6f60383e..b453121f4 100644 --- a/packages/void/test/unit/platform-setup-flow.test.ts +++ b/packages/void/test/unit/platform-setup-flow.test.ts @@ -18,6 +18,7 @@ import { parsePlatformArgs } from '../../src/cli/platform-args.ts'; import { PlatformCloudflareApiError, PlatformCloudflareClient, + PlatformCloudflarePrerequisiteError, verifyPlatformRuntimeTokenEmailPermissions, } from '../../src/cli/platform-cloudflare.ts'; import { formatPlatformCredentialDenials } from '../../src/cli/platform-credential-label.ts'; @@ -179,6 +180,7 @@ beforeEach(() => { { id: 'account', name: 'Account' }, ]); vi.spyOn(PlatformCloudflareClient.prototype, 'listHyperdriveConfigs').mockResolvedValue([]); + vi.spyOn(PlatformCloudflareClient.prototype, 'listDispatchNamespaces').mockResolvedValue([]); mocks.confirm.mockResolvedValue(true); mocks.spinner.mockReturnValue(mocks.progress); mocks.select.mockImplementation(async ({ message, options }) => @@ -393,6 +395,37 @@ function accessManagementPlan() { return [...args, '--login-methods', 'cloudflare-access', '--access-protection']; } +describe('early Workers for Platforms check', () => { + it('stops right after the account is chosen when Workers for Platforms is off', async () => { + vi.mocked(PlatformCloudflareClient.prototype.listDispatchNamespaces).mockRejectedValue( + new PlatformCloudflarePrerequisiteError( + 'Cloudflare Workers for Platforms requires a paid subscription for this account (code 10121).', + new PlatformCloudflareApiError( + 'denied', + 403, + '/accounts/account/workers/dispatch/namespaces', + ), + ), + ); + + await expect( + runPlatformLifecycleCommand( + parsePlatformArgs(['install', '--name', 'test-setup', '--account', 'account']), + ), + ).rejects.toThrow('Workers for Platforms requires a paid subscription'); + + expect(PlatformCloudflareClient.prototype.listDispatchNamespaces).toHaveBeenCalledWith( + 'account', + ); + expect(mocks.select).not.toHaveBeenCalledWith( + expect.objectContaining({ message: 'Where should your apps live?' }), + ); + expect(mocks.plan).not.toHaveBeenCalled(); + expect(listSavedPlatformInstallPlans()).toEqual([]); + expect(listInstallationManifests()).toEqual([]); + }); +}); + describe('platform credential onboarding', () => { it('shows discovery progress around remote reads without covering authentication', async () => { const steps = vi.spyOn(log, 'step').mockImplementation(() => {}); From 4a54151553feba9e0935d17691605783f9a1bcce Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Tue, 1 Dec 2026 09:56:26 +0900 Subject: [PATCH 2/2] Show progress while checking Workers for Platforms. --- packages/void/src/cli/platform-lifecycle.ts | 4 +++- packages/void/test/unit/platform-setup-flow.test.ts | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/void/src/cli/platform-lifecycle.ts b/packages/void/src/cli/platform-lifecycle.ts index 81d071289..1573782b4 100644 --- a/packages/void/src/cli/platform-lifecycle.ts +++ b/packages/void/src/cli/platform-lifecycle.ts @@ -397,7 +397,9 @@ export async function runPlatformLifecycleCommand(commandArgs: PlatformArgs): Pr // repeats this read and reports permission denials together, so only the // missing-product error stops here. try { - await client.listDispatchNamespaces(accountId); + await withPlatformProgress('Checking Workers for Platforms', () => + client.listDispatchNamespaces(accountId), + ); } catch (error) { if (error instanceof PlatformCloudflarePrerequisiteError) { throw error; diff --git a/packages/void/test/unit/platform-setup-flow.test.ts b/packages/void/test/unit/platform-setup-flow.test.ts index b453121f4..a7efefa40 100644 --- a/packages/void/test/unit/platform-setup-flow.test.ts +++ b/packages/void/test/unit/platform-setup-flow.test.ts @@ -397,7 +397,8 @@ function accessManagementPlan() { describe('early Workers for Platforms check', () => { it('stops right after the account is chosen when Workers for Platforms is off', async () => { - vi.mocked(PlatformCloudflareClient.prototype.listDispatchNamespaces).mockRejectedValue( + const listNamespaces = vi.mocked(PlatformCloudflareClient.prototype.listDispatchNamespaces); + listNamespaces.mockRejectedValue( new PlatformCloudflarePrerequisiteError( 'Cloudflare Workers for Platforms requires a paid subscription for this account (code 10121).', new PlatformCloudflareApiError( @@ -414,9 +415,11 @@ describe('early Workers for Platforms check', () => { ), ).rejects.toThrow('Workers for Platforms requires a paid subscription'); - expect(PlatformCloudflareClient.prototype.listDispatchNamespaces).toHaveBeenCalledWith( - 'account', - ); + expect(listNamespaces).toHaveBeenCalledWith('account'); + expect(mocks.progress.start).toHaveBeenLastCalledWith('Checking Workers for Platforms'); + const [namespaceRead] = listNamespaces.mock.invocationCallOrder; + expect(mocks.progress.start.mock.invocationCallOrder.at(-1)).toBeLessThan(namespaceRead); + expect(mocks.progress.clear.mock.invocationCallOrder.at(-1)).toBeGreaterThan(namespaceRead); expect(mocks.select).not.toHaveBeenCalledWith( expect.objectContaining({ message: 'Where should your apps live?' }), );