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

Đang mở Phù hợp với người mới
#623 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@scui73414-bot đang làm issue này rồi.

Từ ngày 22/9/2026.

  • #634 của @scui73414-bot — đang mở
  • #636 của @Thy985 — đã đóng, không merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, nodejs
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại src/canonicalIdentityLock.js ở prepareOwnerFile() và kiểm tra chế độ descriptor được sử dụng trước fs.fdatasyncSync(). Tái hiện bằng node index.js hoặc --loop trên Windows; được xem là hoàn tất khi canonical node-credential snapshot và node registration/hello handshake lưu credentials mà không có lỗi EPERM.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
JavaScript
Star
9.1k
Fork
848
Merge trung bình
14 giờ 39 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của EvoMap/evolver

Tất cả issue của EvoMap/evolver

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.