Silent stale output from Haxe compilation server cache after source edits
0 reputation · 02 Mar 2025, 17:58 UTC
0 reputation · 02 Mar 2025, 17:58 UTC
The goal is to determine the correct invalidation policy for the Haxe compilation server's per-file module cache. When the server remains running across incremental builds, edited sources can produce stale output because cached typed modules are reused without any reported failure.
Freshness is currently keyed on filesystem modification times. Edits saved within timestamp granularity, or on filesystems with coarse or unreliable mtimes, may not invalidate the cache. The cache scope is also per-file identity rather than full compilation context, so changes to compiler defines, macro arguments, classpath order, or untracked files may not force recompilation. Behavior may vary across Haxe 4.x releases and platforms, and the server is intended for local iteration rather than reproducible CI builds.
Should invalidation move to content hashing, or remain mtime-based for speed? Should the cache key incorporate compiler defines, macro arguments, and classpath order? Is restarting the compilation server the only dependable way to discard stale modules?
35775 reputation · 03 Mar 2025, 04:58 UTC
Keep mtime-based invalidation for local iteration, but treat a running compilation server as non-authoritative for correctness. Restart the server when you change compiler defines, macro inputs, classpath order, or when you suspect mtime granularity hid an edit. Do not adopt content hashing unless your installed Haxe 4.x build documents it; it is not a version-independent default.
The compilation server keeps an in-memory per-file typed module cache across incremental builds. Freshness is keyed on source path and filesystem modification time. If an edit is saved within the same mtime tick, or on a filesystem with coarse or unreliable mtimes, the server can reuse a stale module and emit stale output without errors. Because the key is per-file identity rather than full compilation context, changes to -D defines, macro arguments, classpath order, or untracked dependencies may also fail to invalidate.
haxe --version, operating system, and filesystem type.haxe --version
Reproduce the stale-output scenario: edit a file, save within the same mtime tick, rebuild through the running server, restart the server, rebuild again, and compare output. Differing output confirms stale cached modules.
Which Haxe 4.x minor release, platform, and filesystem are you using? This determines whether mtime granularity or server caching is the dominant factor and whether any content-hashing option exists in your build.
Content hashing would detect mtime-invisible edits but adds hashing I/O on every incremental check; support in your Haxe version is unverified. Broadening the cache key to defines, macros, and classpath order can cause over-invalidation and higher memory use. These are trade-offs, not confirmed defaults.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 03 Mar 2025, 00:41 UTC
A useful first step is to confirm whether the stale output comes from a persistent haxe --wait server or a fresh compiler invocation, because only the long-lived server retains an in-memory per-file cache across edits. Restarting the server clears that cache and forces re-typing. Whether your Haxe 4.x release invalidates by mtime, supports content hashing, or keys cache entries on defines and classpath order should be checked against that version’s release notes before changing build configuration.