Skip to content

fix: re-save compiled template to disk when source changes#1

Closed
Koan-Bot wants to merge 1 commit intomasterfrom
koan.atoomic/provider-resave-compiled
Closed

fix: re-save compiled template to disk when source changes#1
Koan-Bot wants to merge 1 commit intomasterfrom
koan.atoomic/provider-resave-compiled

Conversation

@Koan-Bot
Copy link
Collaborator

Summary

  • When COMPILE_DIR/COMPILE_EXT is configured, _refresh() recompiles templates whose source has changed on disk — but it never persisted the recompiled output back to the compiled file
  • On cold restart, the stale compiled file would be loaded, serving outdated content
  • One-line fix: pass _compiled_filename() to _compile() in _refresh(), matching the pattern already used in _fetch()

Analysis of original PR abw#197

The original PR #197 proposed two changes:

  1. The _refresh() compiled filename fix — this is the real bug, implemented here
  2. Using _template_modified() in _template_content() — marginal value; _template_content is inherently file-based (opens $path directly), so overriding just the mtime check without overriding content read is inconsistent. Skipped.

Test plan

  • New t/compile6.t — 8 assertions proving the compiled file on disk is updated when source changes
  • Test confirmed to fail without the fix (compiled file retains original content)
  • Full suite: 2978 tests pass

Resolves: abw#98
See also: abw#197


🤖 Generated by Kōan

When COMPILE_DIR/COMPILE_EXT is configured, the first compile of a
template correctly writes the compiled Perl code to disk. However, when
the template source file is later modified and _refresh() recompiles it,
the call to _compile() was missing the compiled filename argument. This
meant the recompiled template was only stored in memory, never persisted
to disk.

On the next cold start, the stale compiled file would be loaded instead
of the updated source, leading to incorrect template output until the
compiled file was manually deleted.

Fix: pass _compiled_filename() to _compile() in _refresh(), matching the
behavior already used in _fetch().

Resolves: abw#98
See also: abw#197

Co-Authored-By: Kōan <noreply@anthropic.com>
@atoomic
Copy link
Owner

atoomic commented Feb 14, 2026

merged by abw#334

@atoomic atoomic closed this Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rt.cpan.org #60640]

2 participants

Comments