`FileSystem.FileHandle.writeFromOffset` ignores its offset and writes at position 0
Chưa có ai nhận issue này.
Đá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
- 82/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
- Lĩnh vực
- operating-systems
Hướng nghiên cứu
Bắt đầu tại điểm vào Gren.Kernel.FileSystem.writeFromOffset và so sánh cách xử lý các đối số của nó với phần triển khai readFromOffset liền kề. Trước tiên, hãy chạy ./run.sh của bản tái hiện; được xem là hoàn tất khi việc ghi hai byte tại offset 5 tạo ra AAAAAZZAAA thay vì ZZAAAAAAAA.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Found against:* gren 0.6.6, gren-lang/core 7.4.2, gren-lang/node 6.1.3, node 22
Reproduction: in https://github.com/gilramir/gren-bug-reports in 2026-09-11-writefromoffset; ./run.sh prints the figure below.
Reproduction
Write ten As, open the file for writing, put two Zs at offset 5, read it
back:
FileSystem.writeFile fsPermission (Bytes.fromString "AAAAAAAAAA") path
|> Task.andThen
(\_ -> FileHandle.openForWrite fsPermission FileHandle.ExpectExisting path)
|> Task.andThen
(\fh ->
FileHandle.writeFromOffset fh 5 (Bytes.fromString "ZZ")
|> Task.andThen (\_ -> FileHandle.close fh)
)
|> Task.andThen (\_ -> FileSystem.readFile fsPermission path)
wrote "ZZ" at offset 5 into "AAAAAAAAAA"
expected AAAAAZZAAA
got ZZAAAAAAAA
The "ZZ"'s were written at offset 0.
Reason
writeFromOffset takes the offset as a plain Int:
{-| Write bytes into a specific location of a file.
-}
writeFromOffset : WriteableFileHandle a -> Int -> Bytes -> Task FileSystem.Error (WriteableFileHandle a)
writeFromOffset =
Gren.Kernel.FileSystem.writeFromOffset
The kernel function behind it reads that argument as a record:
var _FileSystem_writeFromOffset = F3(function (fh, options, bytes) {
return __Scheduler_binding(function (callback) {
_FileSystem_writeHelper(
fh,
bytes,
0,
bytes.byteLength,
options.__$offset,
callback,
);
});
});
options is a number, so options.__$offset is undefined. That is handed to
fs.write as its position, where undefined means "wherever the file
currently is" — which for a freshly opened handle is 0.
So the offset argument has no effect at all. Every writeFromOffset writes
where write would have written.
readFromOffset beside it does take a record, { offset, length }, and is
correct. The kernel function for the write looks like a copy of the read's that
kept the record access after the Gren signature stopped passing one.
- Ngôn ngữ chính
- JavaScript
- Star
- 13
- Fork
- 6
- Merge trung bình
- 3 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 3
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của gren-lang/node
-
breaking enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
-
breaking enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
-
breaking bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Sqlite: Bytes encoder/decoderĐang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Tất cả issue của gren-lang/node
Issue tương tự
-
bug confirmed perf
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
videojs/video.js#9400 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent/scanner bug hive/hosted-available-lke648397-260827-5n31
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
rescript-lang/rescript#8765 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[workshop-sim] Improve: Add a required self-check gate to the agentic-workflows concept pageĐang mởfeedback simulation workshop
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
githubnext/gh-aw-workshop#4417 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Good First Issue]: Add unit tests for NetworkVersionInfoCó thể đã có người làm @attilayener đã nhận hôm nay. Đang mởGood First Issue hacktoberfest
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
hiero-ledger/hiero-sdk-js#4489 ·
Maintainer thường phản hồi trong vòng 1 ngày