Repository navigation
Incorrect slice() from fs.openAsBlob() #53908
Copy link
Copy link
Closed
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Description
Activity
Reproducible:
import fs from 'node:fs'; // await fs.writeFile('file.txt', '123456789') const blob = await fs.openAsBlob('file.txt'); console.log(await blob.text()); console.log(await blob.slice(3).text()); console.log(await blob.slice(3).slice().text());
└─$ node index.mjs 123456789 456789 456- addedfsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
on Jul 17, 2024 It however does not occur with non-fs blobs:
import { Blob } from 'node:buffer'; const blob = new Blob(['123456789']); console.log(await blob.text()); console.log(await blob.slice(3).text()); console.log(await blob.slice(3).slice().text());
└─$ node index.mjs 123456789 456789 456789Hey @redyetidev, could you assign me this issue? I'd like to work on it, if that's alright.
Feel free to work on it, but issues aren't typically assigned (except when they are self assigned).
If you have an improvement, feel free to submit a PR.
Reacted by Hardik Goyal and devstoneLine 854 in cf8e535
new_end = std::min(end.value(), end_);
Should be:new_end = std::min(end.value() + start_, end_);
Reacted by Aviv KellerFeel free to submit a PR with suggestions to the Conway.
- added a commit that references this issue
on Jul 20, 2024 - addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Jul 20, 2024 - added a commit that references this issue
on Jul 22, 2024 - added a commit that references this issue
on Jul 28, 2024 - added a commit that references this issue
on Aug 5, 2024
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Version
v22.5.0
Platform
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
slice()with no arguments should be equivalent toslice(0, length)and return the entire blob; both of those are incorrectly returning something else.What do you see instead?
The returned
Blobobject purports to have the expectedsize, but when it is read it has the wrong length.Additional information
No response