Skip to content

Commit

Permalink
Log Hugo errors on render failure, also resolve Hugo re-renders
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Oct 17, 2024
1 parent 282083b commit 2dbeb24
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func (builder *bookshopSiteBuilder) build(cfg hugolib.BuildCfg) error {
}

err := builder.Sites.Build(cfg, builder.changeEvents()...)
builder.changedFiles = []string{}

if err == nil {
logErrorCount := builder.Sites.NumLogErrors()
Expand Down
1 change: 1 addition & 0 deletions javascript-modules/engines/hugo-engine/lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export class Engine {
let render_attempts = 1;
let buildError = window.buildHugo();
while (buildError && render_attempts < 5) {
console.warn(`Hit a build error when rendering Hugo:\n${window.hugo_wasm_logging.map(l => ` ${l}`).join('\n')}`);
if (this.componentQuack(buildError, window.hugo_wasm_logging) === null) {
// Can't find a template to overwrite and re-render
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Feature: Hugo Bookshop CloudCannon Live Editing Error Boundaries
text: Hello World 02
"""
Then 🌐 There should be no errors
* 🌐 There should be no logs
* 🌐 The selector body>div should contain "Failed to render"
* 🌐 The selector body>div should contain "can't divide the value by 0"
* 🌐 The selector h1:nth-of-type(1) should contain "Hello World 01"
Expand All @@ -83,7 +82,6 @@ Feature: Hugo Bookshop CloudCannon Live Editing Error Boundaries
text: Hello World 02
"""
Then 🌐 There should be no errors
* 🌐 There should be no logs
* 🌐 The selector body>div should contain "Failed to find"
* 🌐 The selector h1:nth-of-type(2) should contain "Hello World 02"

Expand All @@ -105,7 +103,6 @@ Feature: Hugo Bookshop CloudCannon Live Editing Error Boundaries
text: Hello World 02
"""
Then 🌐 There should be no errors
* 🌐 There should be no logs
* 🌐 The selector body>div should contain "Failed to render"
* 🌐 The selector body>div should contain "partial \"nuffin\" not found"
* 🌐 The selector h1:nth-of-type(2) should contain "Hello World 02"

0 comments on commit 2dbeb24

Please sign in to comment.