summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dataqueue/queue.cc4
-rw-r--r--test/parallel/test-blob-file-backed.js17
2 files changed, 19 insertions, 2 deletions
diff --git a/src/dataqueue/queue.cc b/src/dataqueue/queue.cc
index 8224b82eba..8ae28f9d0a 100644
--- a/src/dataqueue/queue.cc
+++ b/src/dataqueue/queue.cc
@@ -817,7 +817,7 @@ class FdEntry final : public EntryImpl {
uint64_t new_start = start_ + start;
uint64_t new_end = end_;
if (end.has_value()) {
- new_end = std::min(end.value() + start, new_end);
+ new_end = std::min(end.value(), end_);
}
CHECK(new_start >= start_);
@@ -881,7 +881,7 @@ class FdEntry final : public EntryImpl {
file,
Local<Object>(),
entry->start_,
- entry->end_)),
+ entry->end_ - entry->start_)),
entry);
}
diff --git a/test/parallel/test-blob-file-backed.js b/test/parallel/test-blob-file-backed.js
index b25137a34c..acf04a4438 100644
--- a/test/parallel/test-blob-file-backed.js
+++ b/test/parallel/test-blob-file-backed.js
@@ -69,6 +69,23 @@ writeFileSync(testfile3, '');
})().then(common.mustCall());
(async () => {
+ // Refs: https://github.com/nodejs/node/issues/47683
+ const blob = await openAsBlob(testfile);
+ const res = blob.slice(10, 20);
+ const ab = await res.arrayBuffer();
+ strictEqual(res.size, ab.byteLength);
+
+ let length = 0;
+ const stream = await res.stream();
+ for await (const chunk of stream)
+ length += chunk.length;
+ strictEqual(res.size, length);
+
+ const res1 = blob.slice(995, 1005);
+ strictEqual(await res1.text(), data.slice(995, 1005));
+})().then(common.mustCall());
+
+(async () => {
const blob = await openAsBlob(testfile2);
const stream = blob.stream();
const read = async () => {