Skip to content

Commit ca785ab

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/secret-placeholder-create-only
# Conflicts: # packages/void/test/unit/cloudflare-operation-process.test.ts
2 parents 970bb41 + 7848d23 commit ca785ab

270 files changed

Lines changed: 11498 additions & 4487 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/scripts/packed-consumer.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ try {
239239
)
240240
.trim()
241241
.split('\n'),
242-
['node_modules/dependency', '.env', '.env.local', '.env.production'],
243-
'Init must ignore local environment files while allowing the example',
242+
['node_modules/dependency', '.env', '.env.local', '.env.production', '.env.example'],
243+
'Init must ignore local environment files',
244244
);
245245
writeFileSync(
246246
join(fixture, '.npmrc'),

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Read the [Void documentation](https://void.cloud) online or use the Markdown gui
3636

3737
`void init` adds a minimal `AGENTS.md` in new projects and asks before changing instructions in existing projects. It also links bundled skills for detected coding agents.
3838

39-
- [Server routes](https://void.cloud/guide/server-routing) and [pages](https://void.cloud/guide/pages-routing/overview)
39+
- [Server routes](https://void.cloud/guide/server-routing), [pages](https://void.cloud/guide/pages-routing/overview), and [error components](https://void.cloud/guide/pages-routing/errors)
4040
- [Database](https://void.cloud/guide/database) and [type safety](https://void.cloud/guide/type-safety)
4141
- [Deployment](https://void.cloud/guide/deployment)
4242
- [Framework integrations](https://void.cloud/integrations/frameworks/overview)

‎TESTING.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,18 @@ or hanging tests when they occur instead of routinely increasing timeouts.
9090
Subprocess and provisioning-lock unit tests start alongside the platform projects so their real
9191
process deadlines can overlap database work. The remaining SDK unit and integration files then
9292
share a scheduling phase. `vp run test:unit` includes `unit`, `unit-pglite`, and `cli-unit`; CI does the same.
93+
The cf runner's transport checks live in `cf-version-transport.test.ts` so real subprocesses do
94+
not serialize the whole runner suite. Both files use the same fixture helpers with per-file
95+
isolated roots and cleanup; keep their real HTTP, process, and deadline assertions.
9396
Unit files and most API integration files use isolated worker threads to reduce startup time. On Linux and macOS,
9497
API integration files and the PGlite unit files (`unit-pglite`, `platform-unit-pglite`) use forks to isolate PGlite's
9598
WebAssembly JIT allocations after native Node 24 crashes in shared worker processes. API tests
9699
that change the process timezone also use forks, because threads cannot change Node's timezone. Select every
97100
API file with `vp test run --project 'platform-api-integration*'`. SDK integration files use forks.
98101
This keeps database engines from competing with all framework compilers at startup. Keep module
99102
isolation enabled: these suites mock globals, keep database state, and exercise real process/lock boundaries.
103+
Cloudflare Vite build/dev suites belong in the integration pool: their native macOS file watchers
104+
can crash Node while a worker thread is being torn down. Keep these suites in separate processes.
100105
The full verification command builds before running the platform's type-aware lint, so it also
101106
works without a pre-existing dashboard `.void/tsconfig.json`.
102107

@@ -107,6 +112,13 @@ cache test results or remove per-file module isolation. The first run primes it;
107112
runs with the same selection and machine load. For a control use `--no-fsModuleCache`; use
108113
`vp test --clearCache` only when diagnosing cache problems, not before ordinary tests.
109114

115+
Forks and real Node subprocesses also reuse Node's JavaScript/TypeScript compile cache under
116+
`node_modules/.cache/node-compile`. This reuses compilation, while every test and subprocess
117+
still executes with its existing isolation. Compare cold and warm runs when changing subprocess
118+
startup. Use `NODE_DISABLE_COMPILE_CACHE=1 vp test run <file>` for a control. Vitest disables
119+
the cache for V8 coverage, and `NODE_V8_COVERAGE` disables it too, to preserve precise coverage
120+
([Node's compile-cache guidance](https://nodejs.org/download/release/v24.15.0/docs/api/module.html#module-compile-cache)).
121+
110122
## Profiling slow tests
111123

112124
Vitest 5's import diagnostics are opt-in so ordinary runs stay quiet:
@@ -143,7 +155,10 @@ repeat those production builds. `vpr test:all` runs the same artifact check loca
143155

144156
Integration sharding uses [measured duration estimates](test/integration-timings.ts), rather than
145157
filename hashes. [The sequencer](test/sequencer.ts) packs the longest files first and starts costly
146-
fixtures early. Estimates affect scheduling only: new files receive a fallback estimate. Refresh
158+
fixtures early. Within a scheduling phase, cached file durations take priority across project
159+
names, so costly SDK units can overlap framework builds. Failed files retain priority and phase
160+
barriers stay intact. Cold runs use fixture estimates and a five-second fallback. These costs
161+
affect ordering only: every selected test still executes. Refresh
147162
the estimates when the suite's costs change materially. Seeded file shuffling remains available
148163
for isolation checks.
149164

‎docs/.vitepress/config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ export default extendConfig(
241241
{ text: 'Layouts & Shared Data', link: '/guide/pages-routing/layouts' },
242242
{ text: 'Loaders & Props', link: '/guide/pages-routing/loaders' },
243243
{ text: 'Actions & Forms', link: '/guide/pages-routing/actions-and-forms' },
244+
{ text: 'Not Found & Errors', link: '/guide/pages-routing/errors' },
244245
{ text: 'View Transitions', link: '/guide/pages-routing/view-transitions' },
245246
{ text: 'Head Management', link: '/guide/pages-routing/head' },
246247
{ text: 'Islands', link: '/guide/pages-routing/islands' },

‎docs/guide/ai.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ account shown by `void cloudflare status`, or set `CLOUDFLARE_API_TOKEN`.
2828

2929
For a team platform, use `void connect <platform-url>` and link your project.
3030
Development requests use that platform's account and usage limits.
31+
If the platform reports that AI is disabled, ask your administrator to enable it.
32+
This also applies to model listing, Markdown conversion, and provider-native requests.
3133

3234
## Basic Usage
3335

‎docs/guide/auth.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ import { getSession, getUser, requireAuth } from 'void/auth';
118118
- `getUser()` returns the current `AuthUser | null`
119119
- `getSession()` returns `{ user, session } | null`
120120
- `requireAuth(c)` returns the authenticated user or throws `401`
121+
- [`getAuth(c)`](../reference/api/auth.md#getauth-c) returns the request's Better Auth instance, with plugin APIs inferred from `auth.ts`, for use with Better Auth helpers.
121122

122123
Import `AuthUser` and `AuthSession` from `void/auth` for type annotations. They include the fields your Better Auth plugins and `user.additionalFields` add, such as `role` from `admin()`. See their fields in the [API reference](../reference/api/auth.md#authuser).
123124

‎docs/guide/database.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,39 @@ npm install arktype
385385

386386
See the [CLI reference](../reference/cli/database.md#database) for connection setup, SQL execution, Studio, exports, and other commands.
387387

388+
## Adopt an existing Drizzle PostgreSQL database {#adopt-existing-drizzle}
389+
390+
You can keep a PostgreSQL database that Drizzle has already migrated. Void tracks applied files separately, so record the existing history before the first Void deployment.
391+
392+
1. Back up the database and pause deployments. Try the procedure on a restored copy first.
393+
2. Set `database: 'pg'` in `void.config.ts`. Keep your existing schema, SQL filenames, and `db/migrations/meta/` directory. Do not regenerate or rename migrations during adoption.
394+
3. Check the database's Drizzle history against `meta/_journal.json` and your SQL files. Match each applied row's `created_at` to the journal entry's `when`, and its `hash` to the SHA-256 of the corresponding SQL file. Drizzle normally stores this history in `drizzle.__drizzle_migrations`; use your configured schema and table if different. If a file cannot be verified, resolve the discrepancy before continuing.
395+
396+
```sql
397+
SELECT hash, created_at FROM drizzle.__drizzle_migrations ORDER BY created_at;
398+
```
399+
400+
4. Save the following as `adopt-void.sql`, replacing the example filenames with **only the migrations verified as already applied to this database**, including `.sql`. Leave new, unapplied files out of the list.
401+
402+
```sql [adopt-void.sql]
403+
BEGIN;
404+
CREATE TABLE IF NOT EXISTS _void_migrations (
405+
name TEXT PRIMARY KEY,
406+
applied_at TEXT NOT NULL
407+
);
408+
INSERT INTO _void_migrations (name, applied_at)
409+
VALUES
410+
('0000_create_users.sql', CURRENT_TIMESTAMP::text),
411+
('0001_add_email.sql', CURRENT_TIMESTAMP::text)
412+
ON CONFLICT (name) DO NOTHING;
413+
COMMIT;
414+
```
415+
416+
5. Run the file against the existing database with your PostgreSQL client, stopping on errors. Use the same database and PostgreSQL search path that Void will use. This records the verified filenames without executing their SQL or changing Drizzle's history.
417+
6. Configure Void's connection to that database and run `void db status`. Verify that only new migrations are pending, then deploy. For direct Cloudflare deployments, provide that database's `DATABASE_URL` in the shell or CI environment running `void deploy`.
418+
419+
Repeat the verification and adoption separately for each database. An entry in one environment's history does not prove that another environment has applied it. Leave Drizzle's history table intact, and use Void for subsequent migrations.
420+
388421
## Hand-written migrations {#hand-written-migrations}
389422

390423
Deploy compares your Drizzle schema with the snapshots in `db/migrations/meta/`. If you have SQL migrations without this metadata, running `void db generate` would create another migration for the same tables.

‎docs/guide/deployment.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ void db generate
3535

3636
Review and commit the SQL, then deploy again. Rollback does not reverse database migrations. See [Database](./database.md) for the local workflow.
3737

38+
When migrations run in a separate release step, or a preview shares an existing database, deploy code without applying application or authentication SQL migrations:
39+
40+
```sh
41+
void deploy --skip-migrations
42+
```
43+
44+
This works with both deployment destinations. Ensure the app supports the database's current schema. Migration files and schema checks still apply, and the next normal deploy applies any pending migrations. See [the deploy options](../reference/cli/deploy.md#void-deploy) and [`void db migrate`](../reference/cli/database.md#void-db-migrate) for supported ways to apply migrations separately.
45+
3846
For D1 on your own Cloudflare account, deploy saves a restore point before applying migrations and prints a [`void db restore`](../reference/cli/database.md#void-db-restore) command. Use it to recover from a bad migration, then fix the migration before deploying again. A restore discards writes made after that point; check that your deployed code works with the restored schema. See the command reference for the recovery steps and retention limits.
3947

4048
### Environment variables

‎docs/guide/edge/revalidation.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export const loader = defineHandler(async (c) => {
6161
});
6262
```
6363

64+
Use a whole-number literal such as `3600`. Void reads the value without running the file, so it ignores an expression such as `60 * 60` or a value re-exported from another module, and prints a warning.
65+
6466
Per-page values take precedence over `void.config.ts` patterns.
6567

6668
A page's `revalidate` export also applies to `routes/` handlers whose URLs match the page pattern. For example, if `pages/[...slug].server.ts` exports `revalidate`, Void can also cache the `GET` response of `routes/now.ts`. Void never caches paths under `/api`. To keep a route handler's response out of the cache, set `x-revalidate: 0` on it. See [Per-response TTL override](#per-response-ttl-override).

‎docs/guide/pages-routing/actions-and-forms.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ For dynamic routes, pass `params` in the options:
173173

174174
```ts
175175
// pages/users/[id].server.ts has an action
176-
const form = useForm('/users/:id', { name: '' }, { params: { id: '42' } });
176+
const form = useForm('/users/[id]', { name: '' }, { params: { id: '42' } });
177177
<Form form={form} method="put">{/* submits to /users/42 */}</Form>
178178
```
179179

@@ -209,7 +209,7 @@ Actions and forms keep the current scroll position when updating the page in pla
209209
Pass `preserveScroll: false` to reset scroll after an in-place update, or `true` to keep it even after a redirect:
210210

211211
```ts
212-
await action('/users/:id?update', {
212+
await action('/users/[id]?update', {
213213
params: { id: '42' },
214214
data: { name: 'Alice' },
215215
preserveScroll: false,
@@ -233,15 +233,15 @@ export const actions = {
233233
update: defineHandler.withValidator({
234234
body: updateUserSchema,
235235
})(async (c, { body }) => {
236-
const { id } = c.req.param() as PageParams<'/users/:id'>;
236+
const { id } = c.req.param() as PageParams<'/users/[id]'>;
237237
await db
238238
.update(users)
239239
.set(body)
240240
.where(eq(users.id, Number(id)));
241241
}),
242242

243243
delete: defineHandler(async (c) => {
244-
const { id } = c.req.param() as PageParams<'/users/:id'>;
244+
const { id } = c.req.param() as PageParams<'/users/[id]'>;
245245
await db.delete(users).where(eq(users.id, Number(id)));
246246
}),
247247
};
@@ -269,7 +269,7 @@ export const actions = {
269269
When a page exports named actions, append `?actionName` to the URL:
270270

271271
```ts
272-
const form = useForm('/users/:id?update', { name: '' }, { params: { id } });
272+
const form = useForm('/users/[id]?update', { name: '' }, { params: { id } });
273273
<Form form={form} method="put">{/* submits to /users/42?update */}</Form>
274274
```
275275

@@ -282,7 +282,7 @@ Use `action()` for a button or other mutation that does not need form state. It
282282
```ts
283283
import { action } from '@void/react'; // or "@void/vue", "@void/svelte", "@void/solid"
284284

285-
const result = await action('/users/:id?delete', {
285+
const result = await action('/users/[id]?delete', {
286286
params: { id: '42' },
287287
method: 'DELETE',
288288
});
@@ -443,6 +443,8 @@ export const action = defineHandler(async (c) => {
443443
});
444444
```
445445

446+
`withValidator({ body })` accepts the same upload. Nested names such as `profile[name]`, `tags[0]`, and `tags[]` are objects and arrays again. A multipart schema has to coerce the rest: booleans arrive as `'1'` or `'0'`, numbers and dates as strings, and `null` as `''`.
447+
446448
Pick the storage key on the server and allow only the file types you expect. See [Serving Files](../storage.md#serving-files) to send them back safely.
447449

448450
## Choosing a Primitive

0 commit comments

Comments
 (0)