Title: Nuxt and Analog with void/nitro: missing nodejs_compat on native deploys, incomplete init notes, and test, type and size gaps · Issue #418 · voidzero-dev/void · GitHub
Open Graph Title: Nuxt and Analog with void/nitro: missing nodejs_compat on native deploys, incomplete init notes, and test, type and size gaps · Issue #418 · voidzero-dev/void
X Title: Nuxt and Analog with void/nitro: missing nodejs_compat on native deploys, incomplete init notes, and test, type and size gaps · Issue #418 · voidzero-dev/void
Description: These apply after #413, which adds the void/nitro module for PostgreSQL and MySQL apps. Problem Area What happens a void deploy --platform cloudflare A pg/MySQL Nuxt app gets no nodejs_compat unless void.config.ts lists it b void init Th...
Open Graph Description: These apply after #413, which adds the void/nitro module for PostgreSQL and MySQL apps. Problem Area What happens a void deploy --platform cloudflare A pg/MySQL Nuxt app gets no nodejs_compat unles...
X Description: These apply after #413, which adds the void/nitro module for PostgreSQL and MySQL apps. Problem Area What happens a void deploy --platform cloudflare A pg/MySQL Nuxt app gets no nodejs_compat unles...
Opengraph URL: https://github.com/voidzero-dev/void/issues/418
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Nuxt and Analog with void/nitro: missing nodejs_compat on native deploys, incomplete init notes, and test, type and size gaps","articleBody":"These apply after #413, which adds the `void/nitro` module for PostgreSQL and MySQL apps.\n\n## Problem\n\n| | Area | What happens |\n| --- | --- | --- |\n| a | `void deploy --platform cloudflare` | A pg/MySQL Nuxt app gets no `nodejs_compat` unless `void.config.ts` lists it |\n| b | `void init` | The printed Nuxt and Analog config does not deploy |\n| c | Analog pg without `void/nitro` | The build fails on `pg-native` before Void's hint |\n| d | CI | No test runs a Nitro-built pg/MySQL Worker in workerd |\n| e | `nuxi typecheck` | TS2307 for `@schema` and TS2561 for `cloudflareDev` |\n| f | Size | Analog MySQL Workers carry 3-4 copies of `mysql2` |\n\n### a. Native deploys can miss `nodejs_compat`\n\n`void deploy --platform cloudflare` writes the Worker config from `void.config.ts` (`cloudflare.compatibility_flags`) plus the Nuxt preset flags. The preset adds only `nodejs_als`. Nothing adds `nodejs_compat` for pg/MySQL, but the drivers need it. The managed `void deploy` adds it.\n\nThe docs page sets `nodejs_compat` in `void.config.ts`, so apps that copy the docs are fine. `void init` writes only `nodejs_als`. For pg and MySQL Nuxt apps without the flag, the generated `.void-wrangler.jsonc` held only `nodejs_als`.\n\nNitro itself reads only `wrangler.json`, `wrangler.jsonc` or `wrangler.toml`, never `.void-wrangler.jsonc`. So every Nuxt build logs:\n\n```\n[nitro] WARN [cloudflare] Node.js compatibility is not enabled.\n```\n\nNitro then uses unenv's Node stubs. `void/nitro` works around this only for the driver and Void's own `node:async_hooks`. Other server code that imports Node modules gets the stubs.\n\n### b. `void init` notes do not give a working config\n\nThe Nuxt note prints only `nitro: { modules: [\"void/nitro\"] }` and `vite: { plugins: [voidPlugin()] }`. The Analog note prints only `analog({ nitro: { modules: [\"nitro-cloudflare-dev\", \"void/nitro\"] } })`. Neither has `preset: 'cloudflare-module'` or `cloudflareDev: { configPath: './.void-wrangler.jsonc' }`, which the docs pages have.\n\nApplied as printed to fresh `create-nuxt` and `create-analog` apps:\n\n- Nuxt dev, pg route: 500 `env: Cloudflare env is unavailable. Use void runtime bindings inside ...`\n- Nuxt build: `Nitro preset: node-server`. The uploaded Worker fails at start: `No such module \"unhead/server\"`.\n- Analog build: also `node-server`. The Worker fails at start: `No such module \"void/_env\"`.\n\nWith the preset and `cloudflareDev` added, both apps work in dev and on a managed deploy (60 of 60 requests ok).\n\n### c. Analog pg without `void/nitro`\n\nAn Analog pg app with a `.server.ts` page load and no `void/nitro` (the old docs config) fails the Nitro build before Void's runtime hint can show:\n\n```\n[nitro] ERROR Error: Cannot resolve \"pg-native\" from \".../node_modules/pg/lib/native/client.js\" and externals are not allowed!\n```\n\nNuxt pg/MySQL and Analog MySQL without the module do show the hint (\"add 'void/nitro' to the Nitro modules\").\n\n### d. No CI test for a Nitro-built pg/MySQL Worker\n\n`packages/void/test/unit/nitro.test.ts` checks the plugin hooks (`:94`) and runs the request scope in Node (`:115`). The Nuxt and Analog playgrounds use D1. Nothing builds a Nitro `cloudflare-module` Worker with pg or MySQL and runs it in workerd. The load checks so far were manual.\n\n### e. `nuxi typecheck` errors in a fresh Nuxt 4 app\n\nFollowing the docs in a fresh `create-nuxt` app (Nuxt 4.6.1):\n\n```\nserver/api/users.get.ts(1,23): error TS2307: Cannot find module '@schema' or its corresponding type declarations.\nnuxt.config.ts(9,5): error TS2561: Object literal may only specify known properties, but 'cloudflareDev' does not exist in type 'ResolveNuxtNitroConfig\u003cNitroConfig>'. Did you mean to write 'cloudflare'?\n```\n\nThe TS2307 comes from the app project. Nuxt's typed `$fetch` routes import `server/api/*` into it, and that project's paths come from Nuxt's top-level `alias`, not from `nitro.alias`. A top-level `alias: { '@schema': resolve(import.meta.dirname, 'db/schema.ts') }` clears it. Both errors also occur with the docs on main.\n\n### f. Several `mysql2` copies in Analog MySQL Workers\n\nManaged Worker upload sizes:\n\n| App | Upload | gzip | `mysql2` copies |\n| --- | --- | --- | --- |\n| Nuxt MySQL (npm) | 3571.09 KiB | 1236.34 KiB | 3 |\n| Analog MySQL (npm) | 4843.69 KiB | 1578.66 KiB | 3 |\n| Analog MySQL (pnpm) | 5600.98 KiB | 1899.53 KiB | 4 |\n| Analog MySQL (pnpm), driver kept external in Vite's SSR build (prototype) | 4806.03 KiB | 1566.39 KiB | 3 |\n\nThe copies are the cron/queue bundle, the migration handler and Nitro's `void/db` chunk. With pnpm, Analog's Vite SSR build cannot resolve `mysql2` from the app root, so it also bundles the driver into the page-load chunk (`users.server-*.js`). Keeping it external saves about 333 KiB gzip. All sizes are under the Workers Free limit (3 MB compressed), but a growing app gets close.\n\n## Repro\n\n- a. `void init` in a Nuxt app, set `database: 'pg'`, keep the generated `void.config.ts` (`nodejs_als` only), add `void/nitro` and the preset, then `void deploy --platform cloudflare`.\n- b. Fresh `create-nuxt` / `create-analog` app, `void init`, apply the printed note as is, `vp dev` and build.\n- c. Analog pg app with a `.server.ts` load that uses `void/db`, `nitro.alias['@schema']` and no `void/nitro`; build.\n- e. Fresh `create-nuxt` app, docs config, `server/api/users.get.ts` importing `@schema`; run `npx nuxi typecheck`.\n- f. Build an Analog MySQL app with pnpm and count `mysql2` copies in the Worker output.\n\n## Cause\n\n- a. `packages/void/src/cli/deploy-cloudflare-static.ts:136` passes only `preset.cloudflareCompatibilityFlags`; `packages/void/src/cli/preset.ts:125-127` gives Nuxt `['nodejs_als']`. The managed path adds `nodejs_compat` for non-D1 dialects in `packages/void/src/cli/deploy-helpers.ts:176-199`. `packages/void/src/cli/init.ts:1322` writes only `nodejs_als`. Nitro's `readWranglerConfig` (nitropack `dist/presets/cloudflare/utils.mjs:174-176`) looks only for `wrangler.json`, `wrangler.jsonc` and `wrangler.toml`; `packages/void/src/plugin-drizzle.ts:441-442` notes this.\n- b. `packages/void/src/cli/init.ts:2373-2402`. On main the Nuxt note had the same gap, and Analog fell back to the generic Vite note.\n- c. Nitro bundles `pg` without Void's driver build, and `pg/lib/native/client.js` requires `pg-native`. The hint is in `packages/void/src/runtime/db.ts:59-70`, which this build never reaches.\n- d. `packages/void/test/unit/nitro.test.ts`; `playground/nuxt` and `playground/analog` are D1 apps.\n- e. Nuxt types server routes for the app project from `nuxt.options.alias`; `cloudflareDev` is not in Nuxt's Nitro config type.\n- f. The `void/db` template imports `drizzle-orm/mysql2` by path (`packages/void/src/plugin-drizzle.ts:18`), and its bare `mysql2` import is inlined by Vite's SSR build when it cannot be resolved from the app root.\n\n## Suggested fix\n\n- a. In the native framework deploy, add `nodejs_compat` for pg/MySQL as the managed path does. Have `void init` write it for pg/MySQL apps.\n- b. Put `preset: 'cloudflare-module'` and `cloudflareDev` in both notes, or link the framework docs page.\n- c. Add a short Analog troubleshooting note that names `void/nitro`.\n- d. Add one test that builds a tiny Nitro `cloudflare-module` app with PGlite or the fake MySQL server and runs concurrent requests in Miniflare.\n- e. Docs: use a top-level Nuxt `alias` for `@schema`, and say how to type `cloudflareDev` (or that the error is harmless).\n- f. For Nitro frameworks, keep the dialect's driver external in Vite's server build so Nitro uses `void/nitro`'s shared driver bundle.\n\n## Evidence\n\n- a. Generated `.void-wrangler.jsonc` for Nuxt pg and MySQL apps held only `nodejs_als`; the Nitro warning is in their build logs. Native deploy flags confirmed by code; a native deploy was not run.\n- b. Runs on fresh apps with the packed head of #413: outputs above.\n- c. Build logs at the head of #413 and at the commit before `void/nitro`: same error.\n- d. Code read.\n- e. `nuxi typecheck` runs in a fresh Nuxt 4.6.1 app with no alias, with `nitro.alias`, and with a top-level alias.\n- f. Managed deploy captures for npm, pnpm, Yarn and Bun layouts; the prototype kept the driver external in the app's Vite config.\n- All items apply after #413. b (Nuxt), c and e also occur before `void/nitro`.\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nhttps://claude.ai/code/session_0123r5HnanmW2VUrZ7VWDufH\n","author":{"url":"https://github.com/Brooooooklyn","@type":"Person","name":"Brooooooklyn"},"datePublished":"2026-10-14T04:05:31Z","url":"https://github.com/voidzero-dev/void/issues/418"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2864fa12-79b1-bc9b-a3b0-559a605706ba |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8F5A:1E0ED9:AC118:E744D:6AFB96BC |
| html-safe-nonce | 2492fa261e3212a679cb004f5bbba4da6683f591d64617ca14632482a087977e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjVBOjFFMEVEOTpBQzExODpFNzQ0RDo2QUZCOTZCQyIsInZpc2l0b3JfaWQiOiI3OTMzMjE4MjA3MTUyNDQ1MTE2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 477784e53eade5881c3342a62af0b6fb49f0cea9a9cf6b22debdfcf7da5fa382 |
| hovercard-subject-tag | issue:5841738582 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/418/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0dab5a5267805ae0bb7dcf72222e2b93b6499ecd431644156abed7084fa19109/voidzero-dev/void/issues/418 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0dab5a5267805ae0bb7dcf72222e2b93b6499ecd431644156abed7084fa19109/voidzero-dev/void/issues/418 |
| og:image:alt | These apply after #413, which adds the void/nitro module for PostgreSQL and MySQL apps. Problem Area What happens a void deploy --platform cloudflare A pg/MySQL Nuxt app gets no nodejs_compat unles... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Brooooooklyn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4f01efe06174a5ba6342fd58e42d02295e0675bedbb465d6bef2dbaec8e46556 |
| turbo-cache-control | no-preview |
| go-import | github.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git |
| octolytics-dimension-user_id | 149750581 |
| octolytics-dimension-user_login | voidzero-dev |
| octolytics-dimension-repository_id | 1164437080 |
| octolytics-dimension-repository_nwo | voidzero-dev/void |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1164437080 |
| octolytics-dimension-repository_network_root_nwo | voidzero-dev/void |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a52db8866b6543b4e83730cd6a6b1360f1a9e4dc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width