From 05184179a44adce1a044dec4df1466d12a9c06a7 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Thu, 5 Mar 2026 15:17:58 +0000 Subject: [PATCH] fix(compiler): fsync output directories after unpack to avoid XFS delayed logging causing corrupt or invisible directory entries during subsequent TypeScript emits --- changelog.md | 7 +++++++ ts/00_commitinfo_data.ts | 2 +- ts/mod_compiler/classes.tscompiler.ts | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 1683000..ff16a22 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2026-03-05 - 4.1.26 - fix(compiler) +fsync output directories after unpack to avoid XFS delayed logging causing corrupt or invisible directory entries during subsequent TypeScript emits + +- Force fsync on each successful output directory (open, fsync, close) before the next compilation step. +- Prevents XFS delayed logging from making directory entries invisible or corrupted during TypeScript emit operations. +- Operation swallows errors if a directory doesn't exist yet; non-breaking fix with small additional IO. + ## 2026-03-05 - 4.1.25 - fix(mod_unpack) flush directory metadata on XFS before reading and use readdirSync-based iteration to avoid missing entries when unpacking diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 8359714..25fae25 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tsbuild', - version: '4.1.25', + version: '4.1.26', description: 'A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.' } diff --git a/ts/mod_compiler/classes.tscompiler.ts b/ts/mod_compiler/classes.tscompiler.ts index 3706b05..dafb279 100644 --- a/ts/mod_compiler/classes.tscompiler.ts +++ b/ts/mod_compiler/classes.tscompiler.ts @@ -405,6 +405,20 @@ export class TsCompiler { successfulOutputDirs.push(destDir); } + // Fsync all output directories to force XFS metadata commit + // before the next compilation step. Without this, XFS delayed logging + // can cause directory entries from previous compilations to become + // invisible or corrupted during subsequent TypeScript emit operations. + for (const dir of successfulOutputDirs) { + try { + const fd = fs.openSync(dir, 'r'); + fs.fsyncSync(fd); + fs.closeSync(fd); + } catch { + // Directory might not exist yet + } + } + // Diagnostic: log all output directory states after each compilation if (!isQuiet && !isJson) { for (const prevDir of successfulOutputDirs) {