From 2dbeb247e2b748b0f1fec83b4f2207f361dd3784 Mon Sep 17 00:00:00 2001 From: Liam Bigelow <40188355+bglw@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:09:03 +1300 Subject: [PATCH] Log Hugo errors on render failure, also resolve Hugo re-renders --- .../engines/hugo-engine/full-hugo-renderer/main.go | 1 - javascript-modules/engines/hugo-engine/lib/engine.js | 1 + .../hugo/live_editing/hugo_bookshop_live_errors.feature | 3 --- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/javascript-modules/engines/hugo-engine/full-hugo-renderer/main.go b/javascript-modules/engines/hugo-engine/full-hugo-renderer/main.go index 1c605c60..533b7a61 100644 --- a/javascript-modules/engines/hugo-engine/full-hugo-renderer/main.go +++ b/javascript-modules/engines/hugo-engine/full-hugo-renderer/main.go @@ -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() diff --git a/javascript-modules/engines/hugo-engine/lib/engine.js b/javascript-modules/engines/hugo-engine/lib/engine.js index 3a748c03..4a8d864d 100644 --- a/javascript-modules/engines/hugo-engine/lib/engine.js +++ b/javascript-modules/engines/hugo-engine/lib/engine.js @@ -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; diff --git a/javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_errors.feature b/javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_errors.feature index b1d0afa0..2a6cbc3e 100644 --- a/javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_errors.feature +++ b/javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_errors.feature @@ -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" @@ -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" @@ -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" \ No newline at end of file