fix(config): use r+ mode for fsync on Windows to prevent migration retry loop
openSync with read-only mode fails fsync on Windows because FlushFileBuffers requires write-permission FD. This caused atomic writes to fail silently, leaving migrated config unwritten and triggering repeated migration + .bak.<timestamp> generation on every startup. Same root cause as PR #3644 (#3643). Hyperplan disappear is a secondary symptom of plugin load instability. Fixes #3877
This commit is contained in:
@@ -16,7 +16,7 @@ export function writeFileAtomically(
|
|||||||
): void {
|
): void {
|
||||||
const tempPath = `${filePath}.tmp`
|
const tempPath = `${filePath}.tmp`
|
||||||
writeFileSync(tempPath, content, "utf-8")
|
writeFileSync(tempPath, content, "utf-8")
|
||||||
const tempFileDescriptor = openSync(tempPath, "r")
|
const tempFileDescriptor = openSync(tempPath, "r+")
|
||||||
try {
|
try {
|
||||||
tolerantFsyncSync(tempFileDescriptor, `writeFileAtomically:${filePath}`, deps.fsyncSync)
|
tolerantFsyncSync(tempFileDescriptor, `writeFileAtomically:${filePath}`, deps.fsyncSync)
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user