fix(compiler): defer unpacking until after all compilations and remove diagnostic filesystem syncs to avoid XFS metadata visibility issues
This commit is contained in:
@@ -90,9 +90,9 @@ export class TsUnpacker {
|
||||
* 2. Moving contents of the nested source folder up to the dest dir
|
||||
* 3. Removing the now-empty nested source folder
|
||||
*
|
||||
* Uses synchronous fs operations to avoid race conditions with
|
||||
* async readdir returning partial/stale results under signal pressure
|
||||
* or XFS metadata lag (observed in process-group environments like gitzone).
|
||||
* Uses synchronous fs operations for reliability.
|
||||
* Called after all compilations are complete (not between compilations)
|
||||
* to avoid filesystem metadata issues on XFS.
|
||||
*
|
||||
* Returns true if unpacking was performed, false if skipped.
|
||||
*/
|
||||
@@ -107,17 +107,6 @@ export class TsUnpacker {
|
||||
|
||||
const nestedPath = this.getNestedPath();
|
||||
|
||||
// Force XFS to flush pending directory metadata before reading.
|
||||
// XFS delayed logging (CIL) can defer metadata commits, causing
|
||||
// readdirSync/opendirSync to return incomplete results immediately
|
||||
// after TypeScript's emit() creates files via writeFileSync.
|
||||
const destFd = fs.openSync(this.destDir, 'r');
|
||||
fs.fsyncSync(destFd);
|
||||
fs.closeSync(destFd);
|
||||
const nestedFd = fs.openSync(nestedPath, 'r');
|
||||
fs.fsyncSync(nestedFd);
|
||||
fs.closeSync(nestedFd);
|
||||
|
||||
// Step 1: Remove sibling entries (everything in dest except the source folder)
|
||||
const destEntries = fs.readdirSync(this.destDir);
|
||||
for (const entry of destEntries) {
|
||||
@@ -138,9 +127,7 @@ export class TsUnpacker {
|
||||
// Step 3: Remove the now-empty nested directory
|
||||
fs.rmdirSync(nestedPath);
|
||||
|
||||
// Diagnostic: verify final state
|
||||
const finalEntries = fs.readdirSync(this.destDir);
|
||||
console.log(` 📦 Unpacked ${this.sourceFolderName}: moved ${nestedEntries.length} entries, final: ${finalEntries.length} entries`);
|
||||
console.log(` 📦 Unpacked ${this.sourceFolderName}: ${nestedEntries.length} entries`);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user