Skip to content

Commit d431f30

Browse files
committed
fix(void): Surface Hyperdrive provisioning failures.
1 parent e7b863f commit d431f30

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎docs/guide/database/postgresql.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Add to your `void.json`:
2929
For local development, add `DATABASE_URL` to `.env.local`:
3030

3131
```
32-
DATABASE_URL=postgres://user:password@host:5432/mydb
32+
DATABASE_URL=postgresql://user:password@host:5432/mydb?sslmode=require
3333
```
3434

3535
This connects directly to your Postgres database during local Vite development.
@@ -40,10 +40,11 @@ On your first deploy, the CLI will prompt for your connection string:
4040

4141
```
4242
Your project uses PostgreSQL. Enter your connection string:
43-
> postgres://user:password@host:5432/mydb
43+
> postgresql://user:password@host:5432/mydb?sslmode=require
4444
```
4545

4646
Void provisions a Hyperdrive configuration and stores only the config ID. Your connection string is sent directly to Cloudflare's API and is never stored by Void.
47+
Both `postgres://` and `postgresql://` URLs are supported, including provider-supplied query strings such as `?sslmode=require`.
4748

4849
You can also set the connection string ahead of time with `void db set-url`.
4950

‎docs/reference/cli.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Rename existing migrations from the old numeric prefix format (`0001_name.sql`)
313313

314314
### `void db set-url`
315315

316-
Update the PostgreSQL connection string for deployment. Only available for projects with `database.dialect: "postgresql"`.
316+
Update the PostgreSQL connection string for deployment. Only available for projects with `"database": "pg"` in `void.json`.
317317

318318
Prompts for a connection string and sends it to the platform API to create or update the Hyperdrive configuration.
319319

‎packages/void/src/cli/deploy.ts‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,13 @@ async function runFrameworkDeploy(
11151115

11161116
// Pre-deploy: ensure Hyperdrive is provisioned for PostgreSQL projects
11171117
if (dialect === 'postgresql' && (bindings.needsD1 || rawMigrations.length > 0)) {
1118+
let resources: Array<ResourceSummary> | null = null;
11181119
try {
1119-
const resources = await client.getResources(config.projectId);
1120+
resources = await client.getResources(config.projectId);
1121+
} catch {
1122+
// Resources endpoint not available
1123+
}
1124+
if (resources) {
11201125
const hasHyperdrive = resources.some(
11211126
(resource: ResourceSummary) => resource.type === 'hyperdrive',
11221127
);
@@ -1138,8 +1143,6 @@ async function runFrameworkDeploy(
11381143
await client.provisionDatabase(config.projectId, connectionString as string);
11391144
log.success('Hyperdrive provisioned.');
11401145
}
1141-
} catch {
1142-
// Resources endpoint not available
11431146
}
11441147
}
11451148

@@ -1478,8 +1481,13 @@ async function runFullDeploy(
14781481
// Migrations on disk also gate this — even if inference says needsD1: false,
14791482
// buildVoidManifest will add the hyperdrive binding when migrations are present.
14801483
if (dialect === 'postgresql' && (effectiveBindings.needsD1 || rawMigrations.length > 0)) {
1484+
let resources: Array<ResourceSummary> | null = null;
14811485
try {
1482-
const resources = await client.getResources(config.projectId);
1486+
resources = await client.getResources(config.projectId);
1487+
} catch {
1488+
// Resources endpoint not available — Hyperdrive will be checked at deploy time
1489+
}
1490+
if (resources) {
14831491
const hasHyperdrive = resources.some(
14841492
(resource: ResourceSummary) => resource.type === 'hyperdrive',
14851493
);
@@ -1501,8 +1509,6 @@ async function runFullDeploy(
15011509
await client.provisionDatabase(config.projectId, connectionString as string);
15021510
log.success('Hyperdrive provisioned.');
15031511
}
1504-
} catch {
1505-
// Resources endpoint not available — Hyperdrive will be checked at deploy time
15061512
}
15071513
}
15081514
const workerDirName = resolveWorkerDirName(distDir, fwPreset, frameworkBuildCmd);

0 commit comments

Comments
 (0)