You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 73dbf57
Browse filesBrowse the repository at this point in the historyBrowse files
fix: report queue options and page settings that Void cannot read (#754)
Void reads queue consumer options from the source without running it,
and only understands `export const name = <literal>`. Every other way of
exporting the same name is skipped without a message. A queue that
shares its options through a module builds and deploys with Cloudflare's
defaults:
```ts
// queues/_options.ts
export const maxRetries = 0;
export const retryDelay = 30;
```
```ts
// queues/emails.ts
import { defineQueue } from 'void';
export { maxRetries, retryDelay } from './_options';
export default defineQueue(async (batch) => {
// ...
});
```
The consumer gets `maxRetries` 3 and `retryDelay` 0, so a failing
message is retried three times without delay instead of being dropped.
The same happens with export lists (`export { maxRetries }`), `let` and
`var`, destructuring, and `export * from`. The queues guide only says
"Export named constants".
Page settings are read the same way: `revalidate`, `prerender` and `ssr`
in a page's `.server.ts`, and `layout` in a page component. There, a
computed value is skipped as well: with `export const revalidate = 60 *
60`, the page falls back to `routing.revalidate`.
## Fix
The shared reader in `shared/static-exports.ts` now also reports the
names a scanner asks about that are exported in a form whose value it
cannot read, and whether the module uses `export * from`. Each scanner
decides what to do with them:
- Queue options in another form fail the build, as computed values
already did:
```
queue: maxRetries in 'emails.ts' must be declared in the queue file as
`export const maxRetries = <integer>`. Re-exported options and other
export forms are not read.
```
- Page settings that cannot be read are still ignored, but print a
warning once per file. A hard error would break builds that ship them
today, which is also why #433 made layout paths a warning.
- `export * from` in a queue file, a page's `.server.ts` or a page
component prints a warning, since Void cannot tell which names it brings
in. The check that decides whether to parse a file skips whitespace and
comments, so `export /* shared */ * from` counts too. A queue file that
declares all four options, or a page that declares its own layout, gets
no warning: its own exports take precedence.
- In a `.server.ts`, that warning also names `loader`, `action`,
`actions` and `getPrerenderPaths`. Page method detection doesn't follow
`export *` either, which affects automatic prerendering, action types
and the prerender path list.
- Exports in a Svelte instance script declare component props, so
`export let layout` there is not read as a layout setting and gets no
warning. A layout in a later `<script module>` is still found.
Type-only exports are ignored. Values written as `export const name =
<literal>` are read as before. The cron scanner moves to the new reader
without a change in behavior.
The queues, revalidation, Pages overview and layouts guides now say that
these values must be literals declared with `export const` in the file
itself.
**Behavior change:** an app that shares queue options through another
module now fails to build until each queue file declares them. Those
values were never applied.
## Tests
- `packages/void/test/unit/queue-scan.test.ts`: re-exports, export
lists, a renamed local, `let` and destructuring fail with the message
above. `export * from` warns once, also with a comment or line breaks
between `export` and `*`. Type-only exports, and a file that declares
all four options beside `export *`, stay silent.
- `packages/void/test/unit/pages-scan.test.ts`: a computed `revalidate`,
non-boolean `prerender` and `ssr`, re-exported, renamed, `let` and
destructured settings, unreadable and non-string layouts, and `export *`
in server files and components each warn once and keep the default.
Type-only exports and a layout declared beside `export *` stay silent. A
Svelte `<script module>` or `<script context="module">` layout after an
instance prop named `layout` is read, and an instance prop alone gets no
warning.
Each of the 21 new error and warning cases fails without this fix.
## Verification
- `vp test run`: 785 files pass, 1 skipped (16,406 tests pass, 30
skipped).
- `vp run check`: 33/33 pass.
- The React, Vue, Svelte and Solid Pages playgrounds build without new
warnings.
- Not run: `void deploy` against Cloudflare.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
+
64
66
Per-page values take precedence over `void.config.ts` patterns.
65
67
66
68
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).
Copy file name to clipboardExpand all lines: docs/guide/pages-routing/layouts.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -216,6 +216,8 @@ A named layout replaces the deepest default layout: in `[root, docs/layout]`, it
216
216
217
217
Void uses the closest matching `_layouts/` file in the page's directory or an ancestor. A missing named layout fails the build.
218
218
219
+
Declare `layout` in the page file itself with a string literal or `false`. Void reads it without running the page, so it ignores a computed or re-exported value and prints a warning.
220
+
219
221
## Shared Data
220
222
221
223
Middleware can inject data available on every page via `c.set("shared", {...})`. Augment `CloudContextVariables` to type the shared data, and `useShared()` will infer the type automatically:
Copy file name to clipboardExpand all lines: docs/guide/pages-routing/overview.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,6 +153,8 @@ Render and prerender flags combine like this:
153
153
| Island page + `ssr = false`| Invalid. Island pages already use the island renderer. |
154
154
|`output: "static"` + `prerender` unset | Auto-prerender pages that have known paths, including client-only shells. |
155
155
156
+
Write `ssr` and `prerender` as `true` or `false` with `export const` in the `.server.ts` file itself. Void reads them without running the file, so it ignores a computed or re-exported value and prints a warning.
157
+
156
158
### Typed navigation
157
159
158
160
Use the `Link` component for SPA navigation between pages. Build dynamic URLs with [`routeUrl()`](../type-safety.md#typed-urls-and-navigation) to check the route pattern and its parameters:
-`maxRetries`: maximum number of retries before delivery is exhausted (default `3`)
111
111
-`retryDelay`: seconds to wait between retries (default `0`)
112
112
113
+
Declare each option in the queue file with `export const` and a whole-number literal. Void reads these values without running the file, so computed values and options re-exported from another module are not supported. To use the same value in several queues, repeat it in each queue file.
114
+
113
115
Void-managed queues do not configure a dead-letter queue. Cloudflare permanently
114
116
deletes messages that exhaust their retries without one; see
// `export let layout` in a Svelte instance script declares a prop of that name.
142
+
if(script.instance){
143
+
continue;
144
+
}
145
+
exportsAll||=exports.exportsAll;
146
+
if(exports.unreadable.has('layout')){
147
+
ignored??=`pages: layout in '${filename}' is ignored. Declare it in that file as \`export const layout = '<name>'\`; re-exported layouts and other export forms are not read.`;
148
+
}elseif(initializer){
149
+
ignored??=`pages: layout in '${filename}' is ignored. It must be a string literal or \`false\`, such as \`export const layout = 'landing'\`.`;
150
+
}
151
+
}
152
+
if(ignored){
153
+
return{layout: undefined,warnings: [ignored]};
154
+
}
155
+
if(exportsAll){
156
+
return{
157
+
layout: undefined,
158
+
warnings: [
159
+
`pages: '${filename}' uses \`export * from\`. Void does not read a layout export through it, so declare layout in that file with \`export const\`.`,
`pages: ${name} in '${filename}' is ignored. Declare it in that file as \`export const ${name} = ${PAGE_SETTING_PLACEHOLDERS[name]}\`; re-exported settings and other export forms are not read.`,
`pages: revalidate in '${filename}' is ignored. It must be a nonnegative integer literal, such as \`export const revalidate = 3600\`.`,
214
+
);
215
+
}
216
+
}elseif(typeofvalue==='boolean'){
217
+
metadata[name]=value;
218
+
}else{
219
+
metadata.warnings.push(
220
+
`pages: ${name} in '${filename}' is ignored. It must be \`true\` or \`false\`.`,
221
+
);
222
+
}
223
+
}
224
+
if(settings.exportsAll){
225
+
metadata.warnings.push(
226
+
`pages: '${filename}' uses \`export * from\`. Void does not see page exports through it, so export loader, action, actions and getPrerenderPaths by name, and declare revalidate, prerender and ssr in that file with \`export const\`.`,
`queue: ${unreadable} in '${filePath}' must be declared in the queue file as \`export const ${unreadable} = <integer>\`. Re-exported options and other export forms are not read.`,
`queue: '${filePath}' uses \`export * from\`. Void does not read consumer options through it, so declare them in the queue file with \`export const\`. Re-export other names individually to remove this warning.`,
0 commit comments