Repository navigation
Commit ce60d48
fix: resolve island CSS paths and deploy compat flag mismatch (#71)
## Control flow analysis
### Build time (works)
1. User runs `void deploy` from `playground/react-pages/`
2. The CLI shells out to `vite build`, which invokes
`@cloudflare/vite-plugin`
3. The plugin builds two environments: **client** (browser JS) and
**ssr** (worker bundle)
4. During the SSR build, the virtual renderer module is generated:
```js
import React from "react";
import { renderToString } from "react-dom/server";
import { SharedContext, ErrorsContext, RouterContext } from
"@void/react";
```
5. `@void/react` is a pre-built npm package whose dist imports `{
createContext, useContext } from "react"`
6. Rolldown bundles everything into a module graph under `dist/ssr/` --
`index.js` + `assets/*.js` chunks
7. React ends up in a single CJS-wrapped chunk (`react-BVLPaBiV.js`)
shared by all consumers. **No dual React.**
8. `@cloudflare/vite-plugin` writes `dist/ssr/wrangler.json` with
`compatibility_flags: ["nodejs_als"]` and `compatibility_date:
"2026-03-29"`
### Deploy packaging (the first bug)
9. The CLI calls `readWranglerCompat(root, config)` to get compat
settings for the deploy manifest
10. It looks for `wrangler.json` at the **project root**
(`playground/react-pages/`) -- **does not exist**
11. It looks for `worker.compatibility_flags` in `void.json` -- **not
set**
12. Falls back to hardcoded defaults: `compatibility_date:
"2026-02-12"`, `compatibilityFlags: undefined`
13. The build output's `dist/ssr/wrangler.json` (which has the correct
settings) is **never read**
14. The CLI packages all worker files from `dist/ssr/` into a FormData
with the manifest
15. The manifest has `compatibilityFlags: undefined`
### Server-side deploy (the second bug)
16. The platform API (`packages/api/src/routes/deploy.ts`) receives the
FormData
17. It builds WfP upload metadata:
```js
compatibility_flags: manifest.compatibilityFlags ?? ["nodejs_compat"]
```
18. Since `manifest.compatibilityFlags` is `undefined`, the fallback
`["nodejs_compat"]` kicks in
19. The worker is uploaded to Workers for Platforms with:
- `compatibility_flags: ["nodejs_compat"]` (wrong -- should be
`["nodejs_als"]`)
- `compatibility_date: "2026-02-12"` (wrong -- should be `"2026-03-29"`)
### Runtime (the crash)
20. A request hits `https://void-test-it.void.app/`
21. The dispatch worker (`packages/dispatch`) routes it to the user's
WfP worker
22. The worker's `index.js` entry handles the request via Hono
23. The route handler calls `handlePageGet(...)` which calls
`renderPage(pageObj, assetTags)`
24. The virtual renderer builds the React element tree:
```js
element = React.createElement(SharedContext.Provider, { value: shared },
React.createElement(ErrorsContext.Provider, { value: errors },
React.createElement(RouterContext.Provider, { value: null },
React.createElement(Layout, null,
React.createElement(HomePage, props)))))
```
25. It calls `renderToString(element)` -- this enters React's server
renderer
26. React's server renderer sets `ReactSharedInternals.H =
serverDispatcher` and begins rendering
27. The `Layout` component runs, calls `useShared()` ->
`useContext(SharedContext)`
28. `useContext` internally does
`ReactSharedInternals.H.useContext(context)`
29. **Under `nodejs_compat` at compat date `2026-02-12` on WfP**,
`ReactSharedInternals.H` is `null` at this point -- the dispatcher set
by `renderToString` is not visible to the `useContext` call
30. **`null.useContext`** -> `TypeError: Cannot read properties of null
(reading 'useContext')`
31. The worker returns 500
### Why it works locally
- **`vite dev`**: No bundling. `@void/react` is excluded from dep
optimization (`optimizeDeps.exclude`), so all code shares the same live
React module. `nodejs_als` is used by the Cloudflare plugin's dev
server.
- **`wrangler dev` on build output**: Reads `dist/ssr/wrangler.json`
directly, which has the correct `nodejs_als` flag and `2026-03-29` date.
The local workerd runtime evaluates modules correctly under these
settings.
### The fix
The deploy pipeline now reads the build output's `wrangler.json` as a
fallback source for compat settings (priority: `void.json` > project
`wrangler.json` > build output `wrangler.json` > hardcoded default).
This ensures the deployed worker runs with the same flags the build was
designed for.
Also fixes a separate build failure where island CSS imports with
relative paths (e.g. `import "./global.css"` in a layout) were copied
verbatim into the virtual islands-client entry module, where they could
not resolve. Now rewrites them to absolute paths.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 8bbdfe2 commit ce60d48
9 files changed
Lines changed: 224 additions & 15 deletions
File tree
- packages
- react/src
- solid/src
- svelte/src
- void
- src
- cli
- pages
- test/unit
- vue/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
375 | 376 | | |
376 | 377 | | |
377 | 378 | | |
378 | | - | |
| 379 | + | |
379 | 380 | | |
380 | 381 | | |
381 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
397 | 398 | | |
398 | 399 | | |
399 | 400 | | |
400 | | - | |
| 401 | + | |
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
441 | 442 | | |
442 | 443 | | |
443 | 444 | | |
444 | | - | |
| 445 | + | |
445 | 446 | | |
446 | 447 | | |
447 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
519 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
520 | 523 | | |
521 | 524 | | |
522 | 525 | | |
| |||
837 | 840 | | |
838 | 841 | | |
839 | 842 | | |
840 | | - | |
841 | | - | |
| 843 | + | |
| 844 | + | |
842 | 845 | | |
843 | 846 | | |
844 | 847 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | | - | |
27 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
| |||
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
58 | 87 | | |
59 | 88 | | |
60 | 89 | | |
61 | 90 | | |
62 | | - | |
| 91 | + | |
63 | 92 | | |
64 | | - | |
| 93 | + | |
65 | 94 | | |
66 | 95 | | |
67 | | - | |
| 96 | + | |
68 | 97 | | |
69 | 98 | | |
70 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
78 | 94 | | |
79 | 95 | | |
80 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
137 | 233 | | |
138 | 234 | | |
139 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
442 | 443 | | |
443 | 444 | | |
444 | 445 | | |
445 | | - | |
| 446 | + | |
446 | 447 | | |
447 | 448 | | |
448 | 449 | | |
| |||
0 commit comments