From eed134a25ce59f56414c045fa179741ab83e7e64 Mon Sep 17 00:00:00 2001 From: chick Date: Mon, 7 Sep 2026 01:07:16 +0800 Subject: [PATCH] fix: honor underscore-unused convention and make durability fsyncs cross-platform - eslint: respect the repo's existing _-prefix convention for unused vars - phase-one-blockers: derive projectRoot via import.meta.dirname so Windows checkouts stop producing C:\C:\... paths - backup/release-evidence/cutover-orchestrator: skip POSIX-only directory fsync on win32 and fsync read-only handles through a writable handle --- apps/api/src/cutover-orchestrator.ts | 13 ++++++++----- apps/api/src/infrastructure/database/backup.ts | 4 +++- apps/api/src/release-evidence.ts | 13 ++++++++----- eslint.config.js | 8 ++++++++ test/phase-one-blockers.test.js | 2 +- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/api/src/cutover-orchestrator.ts b/apps/api/src/cutover-orchestrator.ts index 8f466d4..19901e5 100644 --- a/apps/api/src/cutover-orchestrator.ts +++ b/apps/api/src/cutover-orchestrator.ts @@ -289,11 +289,14 @@ async function durableState(plan: CutoverPlan, state: CutoverState): Promise { } async function syncFile(path: string): Promise { - const handle = await open(path, 'r'); + // Windows FlushFileBuffers requires a writable handle; POSIX allows fsync on 'r'. + const handle = await open(path, process.platform === 'win32' ? 'r+' : 'r'); try { await handle.sync(); } finally { @@ -168,6 +169,7 @@ async function syncFile(path: string): Promise { } async function syncDirectory(path: string): Promise { + if (process.platform === 'win32') return; // directory fsync only exists on POSIX const handle = await open(path, 'r'); try { await handle.sync(); diff --git a/apps/api/src/release-evidence.ts b/apps/api/src/release-evidence.ts index aafecbe..71f8bdc 100644 --- a/apps/api/src/release-evidence.ts +++ b/apps/api/src/release-evidence.ts @@ -254,11 +254,14 @@ export async function appendReleaseEvidence( await handle.close(); } await rename(temporary, absolute); - const directory = await open(parent, 'r'); - try { - await directory.sync(); - } finally { - await directory.close(); + if (process.platform !== 'win32') { + // directory fsync only exists on POSIX + const directory = await open(parent, 'r'); + try { + await directory.sync(); + } finally { + await directory.close(); + } } return Object.freeze(record); } finally { diff --git a/eslint.config.js b/eslint.config.js index d03bf4d..8d5259d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -30,6 +30,14 @@ export default defineConfig( }, rules: { 'no-undef': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }, + ], }, }, ); diff --git a/test/phase-one-blockers.test.js b/test/phase-one-blockers.test.js index ec21915..7bf5424 100644 --- a/test/phase-one-blockers.test.js +++ b/test/phase-one-blockers.test.js @@ -14,7 +14,7 @@ import { RequestCoordinator } from '../public/state/request-coordinator.js' import { createApiClient } from '../public/infrastructure/api-client.js' import { createViewRouter } from '../public/router/view-router.js' -const projectRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..') +const projectRoot = path.resolve(import.meta.dirname, '..') async function files(instances = []) { const dir = await mkdtemp(path.join(tmpdir(), 'msa-blockers-'))