[Windows] fdatasyncSync on read-only fd throws EPERM, blocks node credential snapshot (canonicalIdentityLock.js)

未关闭 适合新手
#623 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@scui73414-bot 已经在做这个了。

开始于 2026年9月22日。

  • #634 来自 @scui73414-bot —— 未关闭
  • #636 来自 @Thy985 —— 已关闭,未合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript, nodejs
领域
backend

调研方向

从 src/canonicalIdentityLock.js 的 prepareOwnerFile() 开始,检查 fs.fdatasyncSync() 之前使用的 descriptor mode。在 Windows 上使用 node index.js 或 --loop 复现;完成的标准是 canonical node-credential snapshot 和 node registration/hello handshake 能够在没有 EPERM 错误的情况下持久化 credentials。

由索引模型根据 Issue 内容生成。

描述

Summary

On Windows, src/canonicalIdentityLock.js opens the owner file in read-only mode and then calls fs.fdatasyncSync() on that descriptor. Windows' fdatasync (backed by FlushFileBuffers) requires a writable handle, so a read-only fd throws EPERM: operation not permitted, fdatasync. This breaks the canonical node-credential snapshot, so node registration / hello handshake cannot persist credentials.

Steps to reproduce

  1. On Windows, clone and npm install.
  2. Run node index.js (or --loop).
  3. Observe the non-fatal errors:
[a2aProtocol] Failed to snapshot canonical node credentials: EPERM
[TaskReceiver] Fetch/claim failed (non-fatal): EPERM: operation not permitted, fdatasync

Minimal repro:

const fs = require('fs');
fs.writeFileSync('x', 'hello');
const fd = fs.openSync('x', 'r'); // read-only
fs.fdatasyncSync(fd);             // throws EPERM on Windows

Root cause

src/canonicalIdentityLock.js, prepareOwnerFile():

descriptor = fs.openSync(preparedOwnerFile, 'r'); // read-only
fs.fdatasyncSync(descriptor);                      // EPERM on win32

fdatasync on a read-only fd is tolerated on Linux/macOS but fails on Windows (FlushFileBuffers -> ERROR_ACCESS_DENIED -> EPERM).

Suggested fix

Open read+write so fdatasync has a writable handle:

descriptor = fs.openSync(preparedOwnerFile, 'r+');
fs.fdatasyncSync(descriptor);

Environment

  • OS: Windows (win32)
  • Node.js: v22.22.2
  • Evolver version: 1.94.0
主要语言
JavaScript
星标
9.1k
派生
848
平均合并
14 小时 39 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

EvoMap/evolver 的其他 Issue

查看 EvoMap/evolver 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。