Repository navigation
Commit fd05217
fix(void): give Nuxt, Analog and deploy cron bundles the app's void/db
Nitro builds a Nuxt or Analog server without Void's Vite plugins, so
every server route got the static D1 client from `void/db`. A
PostgreSQL or MySQL app failed each database request with a missing
`DB` binding, and `db.query` was undefined even on D1 because the
client had no schema. The deploy build of hosted framework cron and
queue handlers had the same gap: it built `void/db` as the D1 client
and could not resolve `@schema`.
Nuxt and Analog apps now add `void/nitro` to their Nitro modules. The
module and the cron/queue handler build share the plugin that serves
the app's own `void/db`, with its dialect, schema and driver, and
resolve `@schema` through the bundler so a schema folder works. Their
Worker builds import a workerd build of pg or mysql2, made the same way
as the migration handler, because Nitro's CommonJS handling and Node
stubs break both drivers in workerd. The pg build loads no `node:fs`,
which workerd provides only from the 2025-09-15 compatibility date.
For PostgreSQL and MySQL the module also runs each request in Void's
request scope and keeps Void's `node:async_hooks` import native, so a
request reuses one pool across its queries instead of opening a
connection per query. The cron/queue handler build does the same for
each cron event and queue batch, as Void apps do. D1 apps keep their
current request and event handling.
A PostgreSQL or MySQL app with no schema file now gets its dialect's
`void/db` in Vite builds too. An app whose bundle still loads the D1
client while it has HYPERDRIVE or DATABASE_URL gets an error that says
to add `void/nitro`. `void init` prints the module step for Nuxt and
Analog. Nuxt apps keep the Nitro `@schema` alias, because Nuxt types
server routes from Nitro's aliases.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0123r5HnanmW2VUrZ7VWDufH1 parent bd1705f commit fd05217
25 files changed
Lines changed: 922 additions & 153 deletions
File tree
- docs
- guide
- integrations/frameworks
- reference
- packages/void
- src
- cli
- runtime
- test
- helpers
- integration
- unit
- playground
- analog
- src/server/routes/api
- nuxt
- server/api
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | 237 | | |
242 | 238 | | |
243 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 43 | + | |
50 | 44 | | |
51 | 45 | | |
52 | 46 | | |
53 | 47 | | |
54 | 48 | | |
55 | 49 | | |
56 | 50 | | |
| 51 | + | |
| 52 | + | |
57 | 53 | | |
58 | 54 | | |
59 | 55 | | |
| |||
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | 97 | | |
106 | 98 | | |
107 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | 93 | | |
96 | 94 | | |
97 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2373 | 2373 | | |
2374 | 2374 | | |
2375 | 2375 | | |
2376 | | - | |
| 2376 | + | |
2377 | 2377 | | |
2378 | 2378 | | |
| 2379 | + | |
2379 | 2380 | | |
2380 | 2381 | | |
2381 | 2382 | | |
2382 | 2383 | | |
2383 | 2384 | | |
2384 | 2385 | | |
2385 | 2386 | | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
2386 | 2404 | | |
2387 | 2405 | | |
2388 | 2406 | | |
| |||
0 commit comments