Description
During alloy dev initial build, some pages arrive at onPageRendered with page.html set to undefined (JavaScript) instead of an empty string or the rendered HTML.
Steps to reproduce
- Register an
onPageRendered hook with the v0.6.0 object API:
alloy.hook("onPageRendered", {}, (page) => {
// page.html is undefined for some pages
if (page.html.includes('something')) { ... }
});
- Run
alloy dev on a site with many pages (e.g., RHDS with 820 pages)
- The initial build fails with:
TypeError: cannot read property 'includes' of undefined
at <anonymous> (01-transforms.js:7:36)
Expected behavior
page.html should always be a string (empty "" is fine, undefined is not). The HookRenderedPayload struct uses json:"html" without omitempty, so Go should always serialize the field.
Workaround
Guard against undefined:
alloy.hook("onPageRendered", {}, (page) => {
if (!page.html) return page;
// ... transform page.html
});
Notes
alloy build works fine — the issue only appears during alloy dev initial build
- The error occurs on "item 0" suggesting it may affect the first page in the batch
buildPageRenderedPayload() calls page.HTML() which returns empty string for nil RenderedBody — so the Go side should be sending "", not omitting the field
Description
During
alloy devinitial build, some pages arrive atonPageRenderedwithpage.htmlset toundefined(JavaScript) instead of an empty string or the rendered HTML.Steps to reproduce
onPageRenderedhook with the v0.6.0 object API:alloy devon a site with many pages (e.g., RHDS with 820 pages)Expected behavior
page.htmlshould always be a string (empty""is fine,undefinedis not). TheHookRenderedPayloadstruct usesjson:"html"withoutomitempty, so Go should always serialize the field.Workaround
Guard against undefined:
Notes
alloy buildworks fine — the issue only appears duringalloy devinitial buildbuildPageRenderedPayload()callspage.HTML()which returns empty string for nilRenderedBody— so the Go side should be sending"", not omitting the field